I don't think I follow your logic. If my task produced a batch Cmd somehow 
(I'm not even sure how I would do that), that would still get passed to my 
success handler in Task.perform. That handler has to produce a single msg 
(i.e. not a Cmd, so batching isn't involved) which is then used by 
Task.perform to produce the Cmd msg. Ultimately, I don't see how anything I 
can do in my task can influence the single-message nature of Task.perform. 

With that said, it's entirely possible that I just misunderstand what's 
going on. To make things concrete, suppose that my fundamental task comes 
from Http.get. How would I manipulate that task (i.e. wrap it or something) 
to have it "return a batch of commands"? That seems like it would certainly 
solve address my needs!

On Wednesday, October 19, 2016 at 1:11:22 PM UTC+2, Rupert Smith wrote:
>
>
>
> 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.

Reply via email to