3 ms·
Full disclosure I haven't used rxjs myself but from this [1] SO answer it seems pretty complex to limit concurrency of functions in a queue. Qew on the other
by arrow7000 6y ago
Full disclosure I haven't used rxjs myself but from this [1] SO answer it seems pretty complex to limit concurrency of functions in a queue.
Qew on the other hand has a much simpler API: you instantiate a queue with the max concurrency and delay set right in the constructor and then all you need to do is push async functions onto it and forget about them.
The queue will take care of limiting concurrency and executing the next function when the first one has completed.
You can use the same queue for your entire application or instantiate different queues for different REST API endpoints for example; setting the max concurrency and required delay between requests for each API depending on their individual rate limits.
[1] https://stackoverflow.com/a/26126750/3229534 https://stackoverflow.com/a/26126750/3229534
- joshribakoff 6y agoFair enough. It’s dead simple in rxjs too, but they lack concrete examples which has held back the library. Thanks for the detailed thoughts. FYI that SO answer is outdated and does a superset of what’s involved in OPs lib. All you need is defer and mergeMap really at least with rxJs v6+