Return.Optics
is a utility library extending Return
with
Monocle
making a clean, concise API for doing Elm component updates
in the context of other updates.
The signatures abbreviations
pmod
is Parent Modelpmsg
is Parent Msgcmod
is Child Modelcmsg
is Child Msgmodell : Monocle.Lens.Lens (Return x model) model
Lens
to the model, the first element of the Return
tuple.
msgl : Monocle.Lens.Lens (Return msg x) (Platform.Cmd.Cmd msg)
Lens
to the msg, the second element of the Return
tuple.
refractl : Monocle.Lens.Lens pmod cmod -> (cmsg -> pmsg) -> (cmod -> Return cmsg cmod) -> Return pmsg pmod -> Return pmsg pmod
Refract in a component's update via a Lens
and a way to merge
the message back along a parent return in the update function.
Return.singleton model
|> case msg of
...
MyComponentMsg msg ->
refractl Model.myComponent MyComponentMsg <|
MyComponent.update msg
refracto : Monocle.Optional.Optional pmod cmod -> (cmsg -> pmsg) -> (cmod -> Return cmsg cmod) -> Return pmsg pmod -> Return pmsg pmod
Refract in a component's update via an Optional
and a way to merge
the message back along a parent return in the update function. If the
getter returns Nothing
then the Return
will not be modified.
Return.singleton model
|> case msg of
...
MyComponentMsg msg ->
refracto Model.myComponent MyComponentMsg <|
MyComponent.update msg