krisajenkins/elm-exts/8.4.0

NOTE: this package is not compatible with Elm 0.19.1

Exts.StartApp

Extensions to the StartApp library.

( sm, Effects sa )
-> ( sm -> m -> m, sa -> a )
-> ( m, Effects a )
-> ( m, Effects a )

It's a very common pattern in an Elm-architecture app that you want to say, "call this sub-update function to get a (submodel, subeffects) pair, then merge the submodel into the main model with this record update, and the subeffects into the main effects by applying this wrapping function.

This function wraps that step up, so this example code:

  case action of
    LoginAction x -> let (newLoginModel, newLoginEffect) = Login.update x model.loginModel
                     in ({model | loginModel <- newLoginModel}
                        ,Effects.map LoginAction newLoginEffect)

...becomes:

  case action of
    LoginAction x -> liftUpdate (Login.update x model.loginModel)
                                ((\v m -> { m | loginModel <- v}), LoginAction)
                                (model, none)