Skip to content

Commit

Permalink
Additional docs on unbuffered shared flow (#2346)
Browse files Browse the repository at this point in the history
  • Loading branch information
elizarov authored Nov 3, 2020
1 parent c35ce7e commit 865c229
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions kotlinx-coroutines-core/common/src/flow/SharedFlow.kt
Original file line number Diff line number Diff line change
@@ -68,6 +68,15 @@ import kotlin.native.concurrent.*
* the `onBufferOverflow` parameter, which is equal to one of the entries of the [BufferOverflow] enum. When a strategy other
* than [SUSPENDED][BufferOverflow.SUSPEND] is configured, emissions to the shared flow never suspend.
*
* ### Unbuffered shared flow
*
* A default implementation of a shared flow that is created with `MutableSharedFlow()` constructor function
* without parameters has no replay cache nor additional buffer.
* [emit][MutableSharedFlow.emit] call to such a shared flow suspends until all subscribers receive the emitted value
* and returns immediately if there are no subscribers.
* Thus, [tryEmit][MutableSharedFlow.tryEmit] call succeeds and returns `true` only if
* there are no subscribers (in which case the emitted value is immediately lost).
*
* ### SharedFlow vs BroadcastChannel
*
* Conceptually shared flow is similar to [BroadcastChannel][BroadcastChannel]

0 comments on commit 865c229

Please # to comment.