Convenience functions for working with updates in Elm
Allows you to conditionally trigger updates based on a predicate. Can be used with the pipeline operator.
For example:
update msg model =
case msg of
SomeMessage i ->
model ! []
|> filter (i > 10)
( andThen update BiggerThanTen
>> andThen update AnotherMessage
>> andThen update EvenMoreMessages
)
|> andThen (update AlwaysTriggeredAfterPredicate)If you want use to the pipeline operator in the nested pipeline, consider a lambda:
|> filter (i > 10)
( \state -> state
|> andThen update BiggerThanTen
|> andThen update AnotherMessage
|> andThen update EvenMoreMessages
)
|> andThen (update AlwaysTriggeredAfterPredicate)Allows you to attach a Cmd to an update pipeline.
For example:
update msg model = model ! []
|> andThen update AMessage
|> addCmd doSomethingWithASideEffectAllows you to attach multiple messages to an update at once.
For example:
update msg model = model ! []
|> sequence update
[ AMessage
, AnotherMessage
, AThirdMessage
]
Allows update call composition. Can be used with the pipeline operator (|>) to chain updates.
For example:
The same can be achieved using
Update.Extra.Infix.(:>).For example: