-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Do not propagate cancellation to the upstream in Flow flat* operators #2964
Conversation
7dcefb9
to
f3ac536
Compare
f3ac536
to
0c2d4e0
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The docs for flattenConcat
still state that it's just an optimized flattenMerge(concurrency = 1)
, but they now have different downstream cancellation behavior. I didn't check the other operators to see if their docs also need to be updated.
kotlinx-coroutines-core/common/test/flow/operators/FlatMapMergeFastPathTest.kt
Show resolved
Hide resolved
I've updated the doc.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I didn't have issues with the change here, only with the fact that the documentation would now be misleading.
…Kotlin#2964) * Do not propagate cancellation to the upstream in Flow flat* operators Fixes Kotlin#2964
…Kotlin#2964) * Do not propagate cancellation to the upstream in Flow flat* operators Fixes Kotlin#2964
A new mental model is now perfectly aligned with the rest of the coroutines:
merge
or inflatMap*
), the cancellation works in one direction as expected -- cancellation of the child is not propagated to the parent. It's especially important when the "virtual child" (flow
returned byflat*
) can have a different cancellation scope (e.g. it can be a separate UI fragment)flattenConcat
, the behaviour stays the sameFixes #2942