--
You received this message because you are subscribed to the Google Groups "Elm Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elm-discuss...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
One way to do this is to extend the view function with two arguments: one is a function to map the counter messages to the parent message space and the other is the parent message that the remove button should send.
--
You received this message because you are subscribed to a topic in the Google Groups "Elm Discuss" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/elm-discuss/H1AUQelu78c/unsubscribe.
To unsubscribe from this group and all its topics, send an email to elm-discuss...@googlegroups.com.
type AddressedMsg =
ToSelf Msg
| ToParent OutMsg
| ToRoot RootMsg
All relevant functions of the component which output ( Model, Cmd Msg ) change to ( Model, Cmd AddressedMsg )
The update function (of any component in the tree) is now:
update : AddressedMsg -> Model -> ( Model, AdressedMsg )
update msg model =
case msg of
ToSelf msg' ->
handleMsg msg' model
ToParent outMsg ->
-- translate outMsg to new message for parent
Inside the view, I bundled my taggers to include the address, e.g. 'ToSelf Increment' to increase counter 'ToParent RemoveMe' to notify parent counter needs to be removed.
Inside parent's update function is similar and the confidentiality is preserved. Whenever the parent of this component is called (e.g Modify 5 msg in case of the counter).
When the Msg is of type ToSelf, then the parent calls the update of the child.
I asked about this as well and tried an approach where you return a three element tuple from the update function. The third element is a message for the parent. This was suggested by Sporto.I built out a basic working example of that approach here: https://github.com/AWaselnuk/elm-nested-list