On Wednesday, October 19, 2016 at 10:51:16 AM UTC+1, Austin Bingham wrote: > > Is there a way to make Task.perform produce a batched "Cmd msg" on success > (or failure, for that matter)? I've got a case where, on success, I want to > send out more than one Msg, but because the success handler for > Task.perform can only generate one msg this isn't straightforward. > > What I'm doing now is creating an intermediate msg from the success > handler. When my update function handles this intermediate msg, it is then > able to generate the batched Cmd of two msgs that I want. This seems to > work well, but it feels like pattern that only exists because of > Task.perform's design. > > So, is there a better way? Am I missing something that would let me remove > this intermediate message, or is that just the way things have to work? >
Task.perform returns a Cmd msg: perform : (x -> msg) -> (a -> msg) -> Task x a -> Cmd msg Cmd.batch produces a Cmd msg: batch : List (Cmd msg) -> Cmd msg So just have your task return a batch of commands, by using batch on a list of commands. Unless I am missing something obvious, this should be easy to accomplish? -- 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.
