refCount method

  1. @override
R 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
R refCount() {
  if (_canReuse(_ConnectableStreamUse.refCount)) {
    return _subject as R;
  }

  StreamSubscription<T>? subscription;
  _subject.onListen = () => subscription = _connection;
  _subject.onCancel = () => subscription?.cancel();

  return _subject as R;
}