The execution of a Cmd.batch list of commands has not ordering guarantee.
What you see is an artifact and you should not treat it as a predictable
way of execution.
The way to think about a Cmd.batch is that they will get executed and you
will eventually get a reply.

If you need a list of tasks executed in order, you need to implement what
you mean by that yourself.
For example, Task.sequence executes all tasks in order and if one fails,
the entire execution fails.
Task.andThen is another way to chain execution where you have access to the
result of the previous execution.
It depends on what you want to happen.



On Fri, May 12, 2017 at 6:36 PM, Frank Bonetti <frank.r.bone...@gmail.com>
wrote:

> If you batch a list of commands, they will be executed in reverse order.
> For example:
>
> Cmd.batch
>     [ Task.perform (always (AddString "first")) (Task.succeed ())
>     , Task.perform (always (AddString "second")) (Task.succeed ())
>     , Task.perform (always (AddString "third")) (Task.succeed ())
>     ]
>
> Will print:
>
> third
> second
> first
>
>
> Has anyone else noticed this behavior? If so, do you know why Cmd.batch
> was implemented this way?
>
> Here's a demo:
> https://ellie-app.com/39NxYQfDCHMa1/0
>
> --
> 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 elm-discuss+unsubscr...@googlegroups.com.
> 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 elm-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to