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

Controlled observables

The last loss-less strategy to deal with backpressure we will see is the controlled() operator. This operator gives the programmer full control of buffers as it lets you buffer all data and request for the amount of data you want anytime.

This operator has the following signature:

observable.controlled(); 

As you can, see this method doesn't receive any parameters.

After creating a controlled() observable, you can use the method request() to request for a given number of items. The request() method has the following signature:

controlledObservable.request(count); 

The parameter count is mandatory:

  • count: This is the number of items to be pulled from the Observable (if absent, it defaults to zero).

An example usage ...

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