flush method

  1. @override
void flush(
  1. TakeCallback<List> callback
)
inherited

Used to extract all buffered messages from the channel. The flush is resolved using the following rules

  • If the channel is closed and there are no buffered messages, then callback is invoked with End
  • Otherwise callback is invoked with all buffered messages.

Implementation

@override
void flush(TakeCallback<List<T?>> callback) {
  if (_isDebugMode) {
    _checkForbiddenStates();
  }

  if (_closed && _buffer.isEmpty) {
    callback._onData([End as T]);
    return;
  }
  callback._onData(_buffer.flush());
}