Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Specify that subscriptionCount not conflating is a guarantee #3934

Merged
merged 1 commit into from Nov 8, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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