Skip to content

Commit

Permalink
Specify that subscriptionCount not conflating is a guarantee
Browse files Browse the repository at this point in the history
Addresses the new comment to #2871
  • Loading branch information
dkhalanskyjb committed Nov 8, 2023
1 parent e69bc2c commit 1f5377f
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion kotlinx-coroutines-core/common/src/flow/SharedFlow.kt
Expand Up @@ -231,7 +231,11 @@ public interface MutableSharedFlow<T> : SharedFlow<T>, FlowCollector<T> {
* .launchIn(scope) // launch it
* ```
*
* Implementation note: the resulting flow **does not** conflate subscription count.
* Usually, [StateFlow] conflates values, but [subscriptionCount] is not conflated.
* This is done so that any subscribers that need to be notified when subscribers appear do
* reliably observe it. With conflation, if a single subscriber appeared and immediately left, those
* collecting [subscriptionCount] could fail to notice it due to `0` immediately conflating the
* subscription count.
*/
public val subscriptionCount: StateFlow<Int>

Expand Down

0 comments on commit 1f5377f

Please sign in to comment.