I make thousands of calls to my server but in order to avoid overloading, I have put in place a concurrency limit of 10 with RxJS:
const calls = new Subject();
calls.pipe(
mergeAll(10)
).subscribe();
while(int < unknown_number){
calls.next(new Observable((observer) => {
// Call the server here
}))
}
The problem is that I don't know how many calls will be made and I need to know when the job is done. One approach is to get when nothing is left in the queue for 5 seconds or so.
How can I do that?