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

The bufferWithTime() operator

The next operator to buffer data lets you buffer data for a certain amount of time. It's called bufferWithTime(). This operator will store data in an array until a given time is elapsed.

The bufferWithTime() method has the following signature:

observable.bufferWithTime(time,[skipTime],[scheduler]); 

The first parameter is mandatory and the other two are optional:

  • time: This is the time in milliseconds to buffer the data, before propagating it
  • skipTime: This is similar to the skip parameter in the bufferWithCount(), but it is the time in milliseconds to skip
  • scheduler: This is used to propagate data

An example of the usage of this method is as follows:

Rx.Observable     .interval(100)     .bufferWithTime(210) 

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