> The execution of a Cmd.batch list of commands has not ordering guarantee.
Do you know that for sure? There's no documentation for Platform.Cmd.batch <http://package.elm-lang.org/packages/elm-lang/core/5.1.1/Platform-Cmd#batch>, so the official stance is unclear. I want to execute these tasks independently, concurrently, in the order they're provided, and for each one to update the model immediately after completion. If one of them fails, the others should still execute. Chaining theses tasks together with Task.map3, Task.andThen or Task.sequence won't work for this use case. Cmd.batch works perfectly for this use case; I just find it strange that it executes the list in reverse order and was wondering if there was a reason behind it. On Friday, May 12, 2017 at 10:53:19 AM UTC-5, Peter Damoc wrote: > > 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 <[email protected] > <javascript:>> 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 [email protected] <javascript:>. >> 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.
