refCount method

  1. @override
Stream<T> refCount()
override

Returns a Stream that stays connected to this ConnectableStream as long as there is at least one subscription to this ConnectableStream.

Implementation

@override
Stream<T> refCount() {
  ConnectableStreamSubscription<T> subscription;

  _subject.onListen = () => subscription = _connect();
  _subject.onCancel = () => subscription.cancel();

  return _subject;
}