SubscriptionStream<T> constructor

SubscriptionStream<T>(StreamSubscription<T> subscription)

Create a single-subscription Stream from subscription.

The subscription should not be paused. This class will not resume prior pauses, so being paused is indistinguishable from not providing any events.

If the subscription doesn't send any done events, neither will this stream. That may be an issue if subscription was made to cancel on an error.

Implementation

SubscriptionStream(StreamSubscription<T> subscription)
    : _source = subscription {
  _source.pause();
  // Clear callbacks to avoid keeping them alive unnecessarily.
  _source.onData(null);
  _source.onError(null);
  _source.onDone(null);
}