asBroadcastStateStream method

StateStream<T> asBroadcastStateStream()

Convert the this StateStream into a new StateStream 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

StateStream<T> asBroadcastStateStream() => _AsBroadcastStateStream(this);