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?
After reading your comment, I think the answer lays in issuing a
completecommand against theSubjectas soon as we know there is no more data to be read from the DB.So, is a sort of pseudo-code, this could be the draft for the solution