asFlow

@FlowPreview fun <T> BroadcastChannel<T>.asFlow(): Flow<T> (source)

Represents the given broadcast channel as a hot flow. Every flow collector will trigger a new broadcast channel subscription.

Cancellation semantics

  1. Flow consumer is cancelled when the original channel is cancelled.
  2. Flow consumer completes normally when the original channel completes (~is closed) normally.
  3. If the flow consumer fails with an exception, subscription is cancelled.