O'Reilly logo

Mastering Reactive JavaScript by Erich de Souza Oliveira

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

RxJS Schedulers

Schedulers are used to determine where a task is going to be executed (current thread, thread pool, and so on).

You can use them to run any type of task that you want, but RxJS Observables use schedulers to propagate data. For this reason, you can optionally define a Scheduler when creating a new Observable.

As you might expect, having control of which execution context you task should run in (or your Observable should process elements in) is specially useful when you are running in a multithread environment.

As RxJS runs in a single-thread environment, other than the default settings, you should be really cautious when using a scheduler to propagate data from an Observable. Incorrect use can block your thread.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required