utility of Cmd
none : model -> ( model, Platform.Cmd.Cmd msg )
create 'Do nothing' command
model |> Command.none
-- ( model, Cmd.none )
map : (msg -> super) -> ( model, Platform.Cmd.Cmd msg ) -> ( model, Platform.Cmd.Cmd super )
map Cmd msg
in command tuple
type Msg
= Sub SubMsg
type SubMsg
= HelloWorld
update : Msg -> Model -> ( Model, Cmd Msg )
update message model =
case message of
Sub msg ->
model |> updateSub msg |> Command.map Sub
updateSub : SubMsg -> Model -> ( Model, Cmd SubMsg )
updateSub message model =
case message of
HelloWorld -> ( model, Cmd.none )
andThen : (model -> ( model, Platform.Cmd.Cmd msg )) -> ( model, Platform.Cmd.Cmd msg ) -> ( model, Platform.Cmd.Cmd msg )
merge 'Cmd msg' in command tuple
type Msg
= HelloWorld
init : ( Model, Cmd Msg )
init =
( (), Cmd.none )
|> Command.andThen updateA
|> Command.andThen updateB
updateA : ( Model, Cmd Msg )
updateA model = ( model, Cmd.none )
updateB : ( Model, Cmd Msg )
updateB model = ( model, Cmd.none )