-
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
Make FlowCollector fun interface, remove redundant extensions #3047
Conversation
* It also saves us from copy-without-imports problem Addresses #3037
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.
Found several implementations of FlowCollector
.
Collect.kt
. That implementation can be replaced with
public suspend inline fun <T> Flow<T>.collectIndexed(crossinline action: suspend (index: Int, value: T) -> Unit) {
var index = 0
collect { value ->
action(checkIndexOverflow(index++), value)
}
}
Limit.kt
. Doesn't simplify easily.- In benchmarks,
FlowPlaysScrabbleOpt
. Simplifies easily.
These simplifications are not obviously better, so it's up to you whether to make them.
I've deliberately avoided touching benchmarks. |
Looks like after this change, coroutines 1.6.0 isn't backward compatible, when |
This change makes the documentation confusing in some places. In In |
@zjuhasz thanks for noticing, shared flow documentation is fixed in #3127
|
…#3047) * It also saves us from the copy-without-imports problem Addresses Kotlin#3037
…#3047) * It also saves us from the copy-without-imports problem Addresses Kotlin#3037
Addresses #3037