Back-to-send sent elements are conflated -- only the the most recently sent value is received, while previously sent elements are lost. Every subscriber immediately receives the most recently sent element. Sender to this broadcast channel never suspends and trySend always succeeds.
A secondary constructor can be used to create an instance of this class that already holds a value. This channel is also created by BroadcastChannel(Channel.CONFLATED) factory function invocation.
This implementation is fully lock-free. In this implementation opening and closing subscription takes O(N) time, where N is the number of subscribers.
Note: This API is obsolete since 1.5.0. It will be deprecated with warning in 1.6.0 and with error in 1.7.0. It is replaced with StateFlow.
Cancels this conflated broadcast channel with an optional cause, same as close. This function closes the channel with the specified cause (unless it was already closed), and cancels all open subscriptions. A cause can be used to specify an error message or to provide other details on a cancellation reason for debugging purposes.
Registers a handler which is synchronously invoked once the channel is closed or the receiving side of this channel is cancelled. Only one handler can be attached to a channel during its lifetime. The handler is invoked when isClosedForSend starts to return true. If the channel is closed already, the handler is invoked immediately.
Sends the value to all subscribed receives and stores this value as the most recent state for future subscribers. This implementation never suspends. It throws exception if the channel isClosedForSend (see close for details).
Sends the value to all subscribed receives and stores this value as the most recent state for future subscribers. This implementation always returns either successful result or closed with an exception.
Clause for the select expression of the send suspending function that selects when the element that is specified as the parameter is sent to the channel. When the clause is selected, the reference to this channel is passed into the corresponding block.