re-frame-http-fx icon indicating copy to clipboard operation
re-frame-http-fx copied to clipboard

Promise.all for vector of requests

Open sirmspencer opened this issue 11 months ago • 4 comments

We can optionally pass in a vector of requests instead of just one. As far as I can tell they are are independently launched and the on success is fired for each when it finished. Is there any pattern we can use to mimic a promise.all? That is the multiple calls have a single on success / on failure event that is called after all of the calls resolve.

sirmspencer avatar Dec 18 '24 21:12 sirmspencer

Some discussion here: https://github.com/day8/re-frame/issues/808

(Not for the promise.all case.)

mike-thompson-day8 avatar Dec 18 '24 21:12 mike-thompson-day8

It doesn't need to actually use promise like the link you sent. The idea is that all requests should run, with a single on success event called at the end.

sirmspencer avatar Mar 13 '25 22:03 sirmspencer

@sirmspencer In this situation, the current idiom is to use an https://github.com/day8/re-frame-async-flow-fx to coordinate multiple async fx. Typically you are likely to need an async flow anyway, as your list of http operations are likely just a part of and overall flow. In our case it is not unusual to engage multiple async flows like a top level :bootstrap flow which in turn kicks off a :load-assets sub flow and waits for it to complete, before it continues.

hipitihop avatar Mar 19 '25 02:03 hipitihop

Thank you, I will take a look.

sirmspencer avatar Mar 24 '25 22:03 sirmspencer