WindowCountStreamTransformer<T> constructor

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

Constructs a StreamTransformer which buffers events into a Stream and emits this Stream 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

WindowCountStreamTransformer(int count, [int startBufferEvery = 0])
    : super(WindowStrategy.onHandler, null,
          onWindowEnd: (List<T> queue) => Stream.fromIterable(queue),
          startBufferEvery: startBufferEvery,
          closeWindowWhen: (Iterable<T> queue) => queue.length == count) {
  if (count == null) throw ArgumentError.notNull('count');
  if (startBufferEvery == null) {
    throw ArgumentError.notNull('startBufferEvery');
  }
  if (count < 1) throw ArgumentError.value(count, 'count');
  if (startBufferEvery < 0) {
    throw ArgumentError.value(startBufferEvery, 'startBufferEvery');
  }
}