Read
Mounting a child
A Component is self-contained: its own model, update, view and subscriptions. A parent mounts one in its view with +> and a key. Each key gets its own instance with its own state.
counter :: App Int CounterAction
counter = component 0 update view
where ...
parentView :: Model -> View () () Model Action
parentView _ =
H.div_ []
[ H.h2_ [] [ "Two independent counters" ]
, "left" +> counter
, "right" +> counter
]The two counters do not share state: clicking one leaves the other alone. When the parent's view stops including a key, that child unmounts (its subs stop, its unmount action fires).
Children talk to their parent by mail: mailParent value in the child's update, and a mailbox on the parent that turns the value into an action. The docs cover it in detail; this lesson mounts children.