BatchedStreamController<T> constructor

BatchedStreamController<T>({
  1. int delay = _defaultBatchDelayMilliseconds,
})

Create batched stream controller.

Collects events from input sink and emits them in batches to the output stream every delay milliseconds. Keeps the original order.

Implementation

BatchedStreamController({
  int delay = _defaultBatchDelayMilliseconds,
})  : _batchDelayMilliseconds = delay,
      _checkDelayMilliseconds = max(delay ~/ 10, 1),
      _inputController = StreamController<T>(),
      _outputController = StreamController<List<T>>() {
  _inputQueue = StreamQueue<T>(_inputController.stream);
  safeUnawaited(_batchAndSendEvents());
}