**Note: ** This library is opinionated. The usage of an OutMsg is a technique to extend The Elm Architecture (TEA) to support child-parent communication. The README covers the design.
The OutMsg pattern has two components:
interpretOutMsg, a function that converts OutMsg values into side-effects (commands and changes to the model)OutMsg values can be captured in the parent's update function, and handled there by interpretOutMsg.
The basic pattern can be extended to return multiple OutMsg using List or to optionally return no OutMsg using Maybe.
#Evaluators
Turn a Maybe OutMsg into effects and model changes.
Has a third argument for a default command that is used when OutMsg is Nothing.
Turn a List OutMsg into effects and model changes.
Takes care of threading the state. When interpreting an OutMsg changes the model, the updated model will be used for subsequent interpretations of OutMsgs. Cmds are accumulated and batched.
Turn a Result error OutMsg into effects and model changes
Has a third argument for a function that turns errors into a command that is used when OutMsg is Err error.
#Mapping
Apply a function over the updated child component.
Apply a function over the Msg from the child.
Apply a function over the child's OutMsg.
#Helpers
Add an outmessage to the normal type that update has. Handy to use in a pipe:
( { model | a = 1 }, Cmd.none )
|> addOutMsg NothingHelper to split the OutMsg from the normal type that update has.
The functions fst and snd can now be used, which can be handy.
Join the component, command and outmessage into a flat tuple.
#Internals
Internal functions that can be used to create custom evaluators.
An evaluator has three basic components:
OutMessage.wrap.This package uses the State package for threading the model through a series of updates and accumulating commands.
Embed a function into State
Evaluate a State model (Cmd msg) given a model, and commands to prepend.
wrap interpretOutMsg myOutMsg
|> run Cmd.none myModel
Turn an
OutMsgvalue into commands and model changes.The arguments are:
interpretOutMsg, a user-defined function that turns OutMsg values into model changes and effects.Example usage: