I want to trigger multiple messages when window resize in subscription.
Something like:
subscription : Model -> Sub Msg
subscription model =
Window.resizes (\{width, height} ->
Sidebar "hide"
Layout "card"
Search <| Name ""
Screen width height
)
How do I active them at once?
I'm also interested in seeing what other would answer. But here is what I would do.
In short, you can make a single parent message which calls other child messages.
andThen
function just helps to concatenate the update calls.
andThen : Msg -> ( Model, Cmd msg ) -> ( Model, Cmd msg )
andThen msg ( model, cmd ) =
let
( newmodel, newcmd ) =
update msg model
in
newmodel ! [ cmd, newcmd ]
update : Msg -> Model -> ( Model, Cmd msg )
update msg model =
case Debug.log "message" msg of
DoABC ->
update DoA model
|> andThen DoB
|> andThen DoC
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With