Reciever<T> constructor

Reciever<T>(
  1. Stream<T> stream
)

Implementation

Reciever(Stream<T> stream) {
  _streamSubscription = stream.listen((data) {
    assert(!_isClosed);
    _buffer.add(Ok(data));
    if (!_waker.isCompleted) {
      _waker.complete();
    }
  }, onError: (Object object, StackTrace stackTrace) {
    assert(!_isClosed);
    _buffer.add(Err(object));
    if (!_waker.isCompleted) {
      _waker.complete();
    }
  }, onDone: () {
    assert(!_isClosed);
    _isClosed = true;
    _streamSubscription.cancel();
    if (!_waker.isCompleted) {
      _waker.complete();
    }
  }, cancelOnError: false);
}