ggpeti/return-optics/1.0.0

Return.Optics

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 Model
  • pmsg is Parent Msg
  • cmod is Child Model
  • cmsg is Child Msg

Optics

modell : Lens (Return x model) model

Lens to the model, the first element of the Return tuple.

msgl : Lens (Return msg x) (Cmd msg)

Lens to the msg, the second element of the Return tuple.

Utilities

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
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