Let's say I want to I download 10,000 files. I can easily build a queue of those 10,000 files (happy to take advice if any of this can be done better),
import request from 'request-promise-native';
import {from} from 'rxjs';
let reqs = [];
for ( let i = 0; i < 10000; i++ ) {
reqs.push(
from(request(`http://bleh.com/${i}`))
)
};
Now I have an array of Rx.JS observable I've created from promises that represent my queue. Now for the behavior of what I want, I want to issue
- Three-concurrent requests to the server
- Upon completion of a request, I would like a new request to fire.
I can create a solution to this problem, but in light of things like the Rxjs queue, which I've never used I'm wondering what the right-most Rxjs way to do this is.
It sounds like you want an equivalent of
forkJoin
that supports a caller-specified maximum number of concurrent subscriptions.It's possible to re-implement
forkJoin
usingmergeMap
and to expose theconcurrent
parameter, like this: