There are two basic patterns that I've seen: You keep the child oblivious to parent actions and just extend the update signature to signify that it sends something upstream
update : Msg -> Model -> (Model, Cmd Msg, Upstream) Here is an example of this: https://github.com/pdamoc/elm-architecture-tutorial/blob/master/examples/4/Counter.elm OR you use a Context for a specialized view that talks in the language of the parent/ancestor type alias Context parentMsg = { toParent : Msg -> parentMsg , someActionName : parentMsg ... } viewWithContext : Context parentMsg -> Model -> Html parentMsg e.g. Here is the Counter view: type alias Context parentMsg = { toParent : Msg -> parentMsg , remove : parentMsg } view : Model -> Html Msg view model = div [] [ button [ onClick Decrement ] [ text "-" ] , div [ countStyle ] [ text (toString model) ] , button [ onClick Increment ] [ text "+" ] ] viewWithContext : Context parentMsg -> Model -> Html parentMsg viewWithContext context model = div [] [ App.map context.toParent (view model) , button [ onClick context.remove ] [ text "X" ] ] and in the parent (CounterList) you do something like viewCounter (id, model) = Counter.viewWithContext (Counter.Context (Modify id) (Remove id) ) model view model = div [] (List.map viewCounter model.counters) On Tue, May 24, 2016 at 7:27 PM, TheGryzor123 <[email protected]> wrote: > I created a child component that is supposed to display notifications > coming from the parent. > > I know how to initialize and listen to a child but here I would like to > tell him to execute actions for me. > > What do you suggest me to do? > > -- > 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.
