Hi Everyone!

I'm confused about why this needs to be so complex?

For example, let's say you have a button child that needs to to communicate 
its state to its parent.
You could create a `currentMsg` property on the child button model like 
this:

type alias ButtonModel = { currentMsg : Msg }

Then when the child button is clicked, capture the current message on that 
same child model:

update message childModel =
  case message of
   Click ->
        { childModel 
            | currentMsg = message
        }

The parent has a reference to that child button in its model:

type alias ParentModel = { button : Button.ButtonModel }

Then in the parent's `update` function, there might be an `UpdateButton` 
message that updates the child button's state and does something based on 
the value of `button.currentMsg` 

 if parentModel.button.currentMsg == Click then -- do something useful

This is how I've handled all my child-to-parent communication in the last 
few apps I've built.

Can someone tell me if this is a bad idea or if there's a crucial part of 
the problem I'm not understanding?
Is there a use case where this would not work?


-- 
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 [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to