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 bufferWithCount() operator

The first method to buffer data is bufferWithCount(). The bufferWithCount() method lets you specify the size of the buffer. With this method, the data will be stored in an array until the size of this array reaches the given count, upon which this array is propagated.

The bufferWithCount() method has the following signature:

observable.bufferWithCount(size,[skip]); 

The first parameter is mandatory and the second is optional:

  • size: This is a number specifying the size of the buffer.
  • skip: This is a number specifying how many items we should skip to create the next buffer. If not provided, it defaults to the size (this way the next buffer will contain only new elements).

Now let's see an example of this method: ...

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