And it helps to not think about the functions "interacting" with each 
other. They don't. A function can call another function. Nothing is 
stopping you from calling the content update function or the user update 
function from another update function, but I find it helps to just factor 
out the common functionality into separate functions that can be called 
from multiple places.

And if you have an update function that needs to update several 
"sub-models", just pass all the sub-models and get the updated sub-models 
back. Or pass the main model and let it update the parts it needs to update.


> The challenge is when there are dependencies between Updaters, for example 
>> the User Profile model might need data from the Session model, the Session 
>> updater might need to send messages to the User updater (Load user profile 
>> when session is updated), or the Content updater may need to check for the 
>> Session updater (get session ID to send as parameter to the API when 
>> fetching content), or some business-specific updater may need to interact 
>> with both the Content updater, the User updater, and the Configuration 
>> updater.
>>
>> In Redux, one would use combineReducers to mount each reducer under its 
>> own path, and then one can trigger actions across reducers. How would you 
>> solve this in Elm?
>>
>
> I find it helps to think not about sending messages to somebody but 
> returning a command. If the session updater needs to load a user profile, 
> it returns a command do to that and you map that onto the user message 
> type. If the user profile needs data from the session model, you pass that 
> data to the view function.
>
> It only gets hard when you try to think of them as separate components. 
> They're not, they are just a collection of functions. 
>

-- 
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to