'How to check pending schedules in queue schedular of RxJS?

I am using this code in for loop: my purpose was to once I get response of 1st request then only it should execute second request then 3rd and so on.

queueScheduler.schedule(() => {
    this.ajaxcall().subscribe((res) => {
        console.log('blah blah blah', res);
    });
});

Now if my loop has 10 request, it means that while 2request is in progress. then 8 requests are in queue. how can I know how many requests are in queue?

How to check that pending requests?



Solution 1:[1]

You are scheduling creation of ajaxcall's, but creating and subscribing to the observable is synchronous (the subscription callback will be called asynchronously, but you don't refer to the queueScheduler there).

Therefore, queueScheduler runs the scheduled task synchronously and queueScheduler.actions is the empty queue.

The queueScheduler only queues up tasks if you call queueScheduler inside of a task run by the queueScheduler.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 vbraun