BufferCountStreamTransformer<T> constructor

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

Constructs a StreamTransformer which buffers events into a List and emits this List whenever its length is equal to count.

A new buffer is created for every n-th event emitted by the Stream that is being transformed, as specified by the startBufferEvery parameter.

If startBufferEvery is omitted or equals 0, then a new buffer is started whenever the previous one reaches a length of count.

Implementation

BufferCountStreamTransformer(int count, [int startBufferEvery = 0])
    : super(WindowStrategy.onHandler, null,
          onWindowEnd: (queue) => queue,
          startBufferEvery: startBufferEvery,
          closeWindowWhen: (queue) => queue.length == count) {
  if (count < 1) throw ArgumentError.value(count, 'count');
  if (startBufferEvery < 0) {
    throw ArgumentError.value(startBufferEvery, 'startBufferEvery');
  }
}