aMSG is not a valid constructor name, perhaps instead AMSG or A_Msg or MsgA
or so, as long as it starts with an uppercase. :-)
On Tuesday, November 15, 2016 at 3:50:36 PM UTC-7, Tim Bezhashvyly wrote:
>
> Thank you. Tried to apply it but my problem is that I'm trying to send
> initialize a request on init:
>
> init : ( Model, Cmd Msg )
> init =
> ( {
> -- my model here
> }
> , getJson
> )
>
> And of course `getJson` is returning `A.Msg`, so even if in B I declare:
>
> type Msg
> = aMSG A.Msg
> | SomeLocalMessage
>
>
> I'm still getting an error that init was expecting `Main.Msg` but got
> `A.Msg`.
>
> Hope I make sense.
>
>
> On Tuesday, November 15, 2016 at 7:40:50 AM UTC+1, Peter Damoc wrote:
>>
>> There used to be a "nesting" set of examples in The Elm Architecture but
>> lately this approach has been discouraged.
>>
>> What you describe here is a kind of decomposition into components.
>>
>> It is recommended that you have one model and you decompose the
>> functionality of update & view using regular functions.
>>
>> If you want to see how this used to be done, take a look at the old
>> CounterPair example:
>>
>> https://github.com/pdamoc/elm-architecture-tutorial/blob/master/examples/2/CounterPair.elm
>>
>> Please note that this code is obsolete.
>>
>>
>>
>>
>> On Mon, Nov 14, 2016 at 4:43 PM, Tim Bezhashvyly <[email protected]>
>> wrote:
>>
>>> I just started digging into Elm so quite possible that my question has a
>>> conceptual problem. Please let me know if so.
>>>
>>> I have a module A which is asynchronously reading data from JSON. Module
>>> A among other things exposes `getJson` function. As the read is processing
>>> data asynchronously it can not just return data structure but returning
>>> it's Msg type instead which is:
>>>
>>> type Msg
>>> = FetchSucceed (Maybe Jobs)
>>> | FetchFail Http.Error
>>>
>>> Now if module B imports module A it can call `getJson` method but it
>>> will only trigger initial call and then has to listen to `FetchSucceed
>>> `:
>>>
>>> update : A.Msg -> A -> (A, Cmd A.Msg)
>>> update msg model =
>>> case msg of
>>> FetchSucceed a ->
>>> (A a, Cmd.none)
>>>
>>> FetchFail _ ->
>>> (model, Cmd.none)
>>>
>>> My question is if module B has it's own command how does `update`
>>> function combines listening to commands from both modules?
>>>
>>> Thanks.
>>>
>>> --
>>> 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.
>>>
>>
>>
>>
>> --
>> There is NO FATE, we are the creators.
>> blog: http://damoc.ro/
>>
>
--
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.