On Friday, July 1, 2016 at 10:15:40 AM UTC-4, Wouter In t Velt wrote: > > Hi Rex, > > I hope I interpret your setup correctly, but it looks like the flow is > more or less: > > > - user clicks a button inside child > - this triggers child's update function > - child's update function stores updates child model (with a message > Click) > - the parent can then access the new function by accessing the child's > model > > Yes, that's correct.
What I do not understand is: you mention an UpdateButton message that the > parent responds to, > > But what triggers this message? > The parent's view, which updates the child's view. In this system I've been using, the parent checks a property on the child, and then decides whether it should react to that change. You're correct that this requires the parent to know what that child's property is (For example, a button's state: Up, Over, Down, Clicked). Is that the dependency you're trying to avoid? > Typically, the parent does not know or care about child model contents or > child model updates. The parent receives child messages, but parent does > not read child messages. Parent simply passes the messages on to the > child's update function, and stores the updated child model. > > > > This separation guarantees that you can modify code in your child > component (e.g. change the child model, add new message types etc), and any > parent will continue to work properly. No need to check or change code in > any other component that imports the child. > > If any parent 'looks inside' the model or the messages of the child, then > this guarantee breaks down. > > > > The discussion here (or at least my interest in this) is: > > How do I communicate a message from a child to parent, while at the same > time maintaining the integrity of the child's model (so no peeking by > parents into child model)? > Thanks for explaining that! -- 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.
