Skip to content

Instantly share code, notes, and snippets.

@freakingawesome
Last active September 22, 2018 19:04
Show Gist options
  • Save freakingawesome/f6adb3aecaf6366d7c97c0b91d9fba1d to your computer and use it in GitHub Desktop.
Save freakingawesome/f6adb3aecaf6366d7c97c0b91d9fba1d to your computer and use it in GitHub Desktop.
import Html exposing (..)
import Html.Events exposing (..)
main : Program Never Model Msg
main =
Html.program
{ init = init
, view = view
, update = update
, subscriptions = \_ -> Sub.none
}
type alias Model =
{ message : String
}
type Msg
= One
| Two
| Three
| ChainMsgs (List Msg)
init = { message = "initializing" } ! []
update msg model =
case msg of
ChainMsgs msgs ->
let
chain msg1 (model1, cmds) =
let (model2, cmds1) = update msg1 model1
in model2 ! [ cmds, cmds1 ]
in
List.foldl chain (model ! []) msgs
_ ->
{ model | message = model.message ++ ", " ++ toString msg } ! []
view model =
div []
[ div []
[ button [ onClick (ChainMsgs [One, Two, Three]) ] [ text "Click me" ]
]
, text model.message
]
@eboCode
Copy link

eboCode commented Sep 22, 2018

An so-39628628.elm rev for 0.19?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment