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.
