Current Thread Schedulers of Rx

Learn about the current thread Scheduler and its usage in RxJS.

We'll cover the following

The currentThread Scheduler is synchronous, just like the immediate Scheduler, but in case we use recursive operators, it enqueues the actions to execute instead of executing them right away.

A recursive operator is an operator that schedules another operator. A good example of a recursive operator is the repeat operator. The repeat operator—if given no parameters—keeps repeating the previous Observable sequence in the chain indefinitely.

We’ll get in trouble if we call the repeat operator on an operator that uses the immediate Scheduler, such as the return operator. Let’s try this by repeating the value 10 and then using the take operator to take only the first value of the repetition. Ideally, the code will print “10” once and then exit:

Get hands-on with 1400+ tech skills courses.