Josh, let's say I have components nested 3 levels deep: MainComponent, 
which contains AdminComponent, which contains 3 components 
[ApplesComponent, OrangesComponent, and BananasComponent]

Each of the 3 child-most components need to load their respective resource 
(apples, oranges, and bananas), and visualize the current loading state 
(not requested, loading, failed, success)

The AppleComponent might have the following msg's:

type Msg
   = LoadApples
   | ApplesLoading
   | ApplesFailure Error
   | ApplesSuccess Data


If it then needs to proxy requests through its direct parent - the 
AdminComponent - the AdminComponent will contain message like:

type Msg
   = LoadAppleComponentApples
   | AppleComponentApplesLoading
   | AppleComponentApplesFailure Error
   | AppleComponentApplesSuccess Data
   ... etc etc for each Component type

Is this still on par with what you're suggesting?


On Tuesday, July 5, 2016 at 6:13:28 PM UTC-4, Josh Adams wrote:
>
> I want to understand what you're saying because it seems I'm missing 
>> something. Let's say we're 3 nested components deep. The deepest child 
>> wants to load a resource. Rather than creating a http Cmd directly, the 
>> child should return a message to its parent asking for the resource. That 
>> parent would then also repeat this process and ask it's parent for the 
>> resource. Eventually the message arrives at the root component, and the 
>> root component can generate the Cmd necessary to fetch the resource - 
>> whether that is from an http request, or a mock service. Is this what 
>> you're suggesting?
>>
>
> That is, essentially, what I'm suggesting, though others here might 
> proffer up different ways to get at the same thing.  In general, though, I 
> like thinking of children as just spewing out Msg and having the results of 
> those flow back into them from the top.
>
>

-- 
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