Using sequence
function you can easily describe a message that calls a list of other messages. It's useful when dealing with semantics of your messages.
Example 1: You are making a game engine, and you need to refresh the screen on every frame.
module Video exposing (..)
type Message = module Video exposing (..)
import Update.Extra exposing (sequence)
-- Model definition [...]
type Message
= ClearBuffer
| DrawToBuffer
| UpdateLogic
| Update
update : Message -> Model -> (Model, Cmd)
update msg model =
case msg of
ClearBuffer ->
-- do something
DrawToBuffer ->
-- do something
UpdateLogic ->
-- do something
Update ->
model ! []
|> sequence update [ ClearBuffer
, DrawToBuffer
, UpdateLogic]