bufferCount method

Stream<List<T>> bufferCount (
  1. int count,
  2. [int startBufferEvery = 0]
)

Buffers a number of values from the source Stream by count then emits the buffer and clears it, and starts a new buffer each startBufferEvery values. If startBufferEvery is not provided, then new buffers are started immediately at the start of the source and when each buffer closes and is emitted.

Example

count is the maximum size of the buffer emitted

RangeStream(1, 4)
  .bufferCount(2)
  .listen(print); // prints [1, 2], [3, 4] done!

Example

if startBufferEvery is 2, then a new buffer will be started on every other value from the source. A new buffer is started at the beginning of the source by default.

RangeStream(1, 5)
  .bufferCount(3, 2)
  .listen(print); // prints [1, 2, 3], [3, 4, 5], [5] done!

Implementation

Stream<List<T>> bufferCount(int count, [int startBufferEvery = 0]) =>
    transform(BufferCountStreamTransformer<T>(count, startBufferEvery));