Skip to content

Commit

Permalink
Specify that subscriptionCount not conflating is a guarantee (#3934)
Browse files Browse the repository at this point in the history
Addresses the new comment to #2871
  • Loading branch information
dkhalanskyjb authored Nov 8, 2023
1 parent e69bc2c commit 3dd48ac
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion kotlinx-coroutines-core/common/src/flow/SharedFlow.kt
Original file line number Diff line number Diff line change
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 3dd48ac

Please sign in to comment.