the-sett / elm-update-helper / Update2

Convenience function for lifting an update function for an inner model and messages into a parent one.

pure : model -> ( model, Platform.Cmd.Cmd msg )

Creates an Update2 with no commands.

pure model =
    ( model, Cmd.none )

map : (a -> b) -> ( a, Platform.Cmd.Cmd msg ) -> ( b, Platform.Cmd.Cmd msg )

Maps a function over the model in an update.

eval : (model -> ( model, Platform.Cmd.Cmd msg )) -> ( model, Platform.Cmd.Cmd msg ) -> ( model, Platform.Cmd.Cmd msg )

Allows the output of an update function that returns type:

( model, Cmd msg )

To have its model evaluated in order to produce a new model, and to create more commands. The commands returned will be appended to those passed in using Cmd.batch.

Note that this allows multiple invokations of the same update function to be invoked recursively. Beware of causing infinite loops while doing this.

lift : (model -> submodel) -> (submodel -> model -> model) -> (submsg -> msg) -> (submsg -> submodel -> ( submodel, Platform.Cmd.Cmd submsg )) -> submsg -> model -> ( model, Platform.Cmd.Cmd msg )

Lifts an update function of type:

update : submsg -> submodel -> ( submodel, Cmd submsg )

Into one that returns:

( model, Cmd msg )

andThen : (model -> ( model, Platform.Cmd.Cmd msg )) -> ( model, Platform.Cmd.Cmd msg ) -> ( model, Platform.Cmd.Cmd msg )

Allows update functions to be chained together. The Cmds will be batched together.

andMap : (model -> ( model2, Platform.Cmd.Cmd msg )) -> ( model, Platform.Cmd.Cmd msg ) -> ( model2, Platform.Cmd.Cmd msg )

Allows update functions that also produce lists of out messages, to be chained together, whilst also transforming the model and outMsg type. The Cmds will be batched together.