Last active
September 22, 2018 19:04
-
-
Save freakingawesome/f6adb3aecaf6366d7c97c0b91d9fba1d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
] | |
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
Hej there, I've worked this into a port sending chain to try to get sequential, rather than concurrent, sends to JSLand: