You can also call the function recursively:

update : Msg -> Model -> ( Model, Cmd Msg )
update msg model =
    case msg of
        IncrementBothCounters ->
            model
            |> update IncrementFirstCounter
            |> fst
            |> update IncrementFirstCounter

        IncrementFirstCounter ->
            ( { model | countFirst = model.countFirst + 1 }, Cmd.none )

        IncrementSecondCounter ->
            ( { model | countSecond = model.countSecond + 1 }, Cmd.none )


If this is more of a simplification of a more complex situation and you
need to process the Cmd from each update, it is better to use Janis'
solution.




On Thu, May 26, 2016 at 5:24 PM, germain <[email protected]> wrote:

> Hi,
>
> This is the plan:
> There is one counter with its button which increments it by one.
> There is another counter with its button which increments it by one.
> And finally there is another button which increments both above counters
> by one.
>
>
> Is it possible to the last button to send a message to the update
> function, which calls the increment messages of each counter ?
>
> Something like,
>
> update : Msg -> Model -> (Model, Cmd Msg)
> update msg model =
>     case msg of
>     IncrementBothCounters ->
>       ( model, pleaseCallTheUpdateFunctionWithTheseMessages [
> IncrementFirstCounter, IncrementSecondCounter ])
>
>     IncrementFirstCounter ->
>       ( { model | countFirst = model.countFirst + 1 }, Cmd.none)
>
>     IncrementSecondCounter ->
>       ( { model | countSecond = model.countSecond + 1 }, Cmd.none)
>
>
> Tks,
> Germain.
>
> --
> 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.

Reply via email to