On Monday, November 28, 2016 at 2:38:13 PM UTC, Rupert Smith wrote: > > On Monday, November 28, 2016 at 2:01:34 PM UTC, [email protected] > wrote: >> >> I feel it will be too messy to keep all this inter-triplet logic here. Is >> there a better way? Maybe something similar to pub/sub or I'm >> fundamentally wrong here? >> > > I've pulled out a message channels pub/sub implementation. >
In view of Richard's comments, you should ignore my pub/sub suggestions for now. I just assumed you had a genuine need for 'out messages' and communication between child modules in a nested TEA - rather than that you should consider restructuring your code to avoid overly modularizing it in the first place. You may be wondering how your login 'widget' can be re-used, as it not only has to display a button but also produce events in reaction to the user clicking the button: loginButton : msg -> Html msg loginButton tagger = button [ onClick tagger ] [ text "Login" ] Is a re-usable button that can be set up to trigger whatever Msg you pass in as an argument - usually called a 'tagger'. The tagger can also be a function if your Msg type takes an argument, then it is 'tagging' its argument as an event to pass to your update function. So a re-usable 'component' in Elm does not need to encapsulate all of events, state and visual elements as Richard describes. But you can very easily build re-usable view elements. Do this as and when you need to re-use stuff by harvesting from your existing view code by introducing parameters. -- 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.
