publishValueSeeded method

ValueConnectableObservable<T> publishValueSeeded(
  1. T seedValue

Convert the current Observable into a ValueConnectableObservable that can be listened to multiple times, providing an initial seeded value. It will not begin emitting items from the original Observable until the connect method is invoked.

This is useful for converting a single-subscription stream into a broadcast Stream that replays the latest emitted value to any new listener. It also provides access to the latest value synchronously.


final source = Observable.fromIterable([1, 2, 3]);
final connectable = source.publishValueSeeded(0);

// Does not print anything at first

// Start listening to the source Observable. Will cause the previous
// line to start printing 0, 1, 2, 3
final subscription = connectable.connect();

// Late subscribers will receive the last emitted value
connectable.listen(print); // Prints 3

// Can access the latest emitted value synchronously. Prints 3

// Stop emitting items from the source stream and close the underlying
// BehaviorSubject


ValueConnectableObservable<T> publishValueSeeded(T seedValue) =>
    ValueConnectableObservable<T>.seeded(this, seedValue);