receiveAsFlow

abstract fun <T : ChannelEvent<T>> receiveAsFlow(key: ChannelEventKey<T>): Flow<T>

Receive events from the bus identified by ChannelEvent.key.

The returned Flow is cold and only one collector is allowed at a time. This make sure all events are consumed.

If you want to collect the flow multiple times, you must share the flow, or must cancel the previous collection before collecting again with a new one.

Throws

if collecting the flow is already collected by another collector.