Calling next with Schedulers

You’ve learned a heaping pile of different ways to create observables throughout this book. The secret you didn’t know was how Rx decides exactly when to send a new value down the chain. The tool Rx uses for this is called a scheduler, and Rx ships many options for you to choose from. By default, every observable does not use a scheduler to plan out events, instead they emit all values synchronously. Run the following code to see this in action:

 .subscribe(next => console.log(next));

This snippet does not pass a scheduler into the of constructor, so it just runs synchronously. This example logs Hello before World. Now, we can add the asap scheduler to the mix, which delays ...

Get Build Reactive Websites with RxJS now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.