Closed dalen closed 5 years ago
Thanks for the issue! Make sure it satisfies this checklist. My human colleagues will appreciate it!
Here is what to expect next, and if anyone wants to comment, keep these things in mind.
Yes that would be great because it would help reduce loading times when doing requests that can be parallelized. Having an Http solution for concurrent request would be great for this would be great.
To be a bit more clear @dalen : Should the API only send request concurrently or also synchronize the responses(succeeding when all requests returned) kind of like a Promise.all()
would do?
Probably also synchronizing the responses I would say, because just sending them concurrently could also be achieved with Cmd.batch
. But the Cmd.batch
approach sometimes forces you to compromise your model design if you actually need a combination of the results in your model instead of each of them separately.
Yeah, the responses should probably be synchronized. Otherwise the separate responses would need separate handling and responses. Maybe some sort of subscription could be setup as an option if you want to subscribe to the progress of the requests.
There is some discussion of this topic here.
The conclusion so far in that thread is that we should get concrete examples of what people want to accomplish with something like Http.parallel2
to learn how errors and progress should be exposed by an API that allows that sort of thing.
My recommendation would be to open an issue on this repo with the title "Example where parallel requests may be ideal" and then fill the body in with the concrete scenario that you ran into in practice. At this phase, I think it's too early to speculate on the particular API that would result from that. Once we get a couple different people sharing examples here in that particular format, I can organize it into one place and see if there is a design that covers everyone nicely.
It would be useful if there was a way to send multiple requests as a single task (and have all of them sent in parallel).
As using
Task.map2
to batch multiple tasks together will just run them in sequence.See https://dev.to/rtfeldman/tour-of-an-open-source-elm-spa/comments/7h2