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

Pausable observables (with buffer)

We already learned how to pause and resume observables in a lossy fashion; now we will see an operator to pause the observable and keep a buffer while paused so we don't lose any data.

The operator to pause and keep a buffer is called pausableBuffered(), and has the following signature:

observable.pausableBuffered(); 

As you can see, it doesn't accept any parameters.

We can see an example of the usage of this operator in the following code:

var pausableObservable = Rx.Observable     .interval(500)     .pausableBuffered(); pausableObservable.subscribe((i)=>console.log(i)); pausableObservable.pause(); setTimeout(()=>{     pausableObservable.resume(); },4000); 

In this example code, we create an Observable and call ...

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