asBroadcastDistinctValueStream method

DistinctValueStream<T> asBroadcastDistinctValueStream()

Convert the this DistinctValueStream into a new DistinctValueStream that can be listened to multiple times, providing an initial value. It will automatically begin emitting items when first listened to, and shut down when no listeners remain.

This is useful for converting a single-subscription stream into a broadcast Stream. It's also useful for providing sync access to the latest emitted value.

Implementation

DistinctValueStream<T> asBroadcastDistinctValueStream() =>
    isBroadcast ? this : _AsBroadcastStream(this);