getto-systems/elm-command/1.0.0

Formerly getto-systems/getto-elm-command. Search finds this package by either name.

Getto.Command

utility of Cmd

Construction

none : model -> ( model, Cmd msg )

create 'Do nothing' command

model |> Command.none
-- ( model, Cmd.none )

Helper

map : (msg -> super) -> ( model, Cmd msg ) -> ( model, 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 )

Chaining

(model -> ( model, Cmd msg ))
-> ( model, Cmd msg )
-> ( model, 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 )