abstract fun tryEmit(value: T): Boolean

Tries to emit a value to this shared flow without suspending. It returns true if the value was emitted successfully. When this function returns false, it means that the call to a plain emit function will suspend until there is a buffer space available.

A shared flow configured with a BufferOverflow strategy other than SUSPEND (either DROP_OLDEST or DROP_LATEST) never suspends on emit, and thus tryEmit to such a shared flow always returns true.

This method is thread-safe and can be safely invoked from concurrent coroutines without external synchronization.


common source
Link copied to clipboard