asyncAdd method

Future<void> asyncAdd(
  1. T event
)

Add an event to the stream. If the stream is full then this method will wait until there is room.

Implementation

Future<void> asyncAdd(T event) async {
  if (_count >= _limit) {
    await _spaceAvailable.future;
  }
  _count++;
  _streamController.add(event);

  if (_count >= _limit) {
    _spaceAvailable = Completer<bool>();
  }
}