Merge Flow operator is missing
See original GitHub issueThe merge()
operator is missing
fun Flow<T>.merge(vararg flows: Flow<T>): Flow<T> = TODO()
Use Case
Representing clicks on a keypad:
val key1: View
val key2: View
val numberClicks: Flow<Int> = merge(
key1.clicks().map { 1 },
key2.clicks().map { 2 }
)
Note: I think fun Flow<T>.merge(otherFlow: Flow<T>): Flow<T>
is an anti-pattern because it creates hard to read flows, so I am intentionally not requesting it 😛
Issue Analytics
- State:
- Created 4 years ago
- Comments:7 (3 by maintainers)
Top Results From Across the Web
Combining flows: merge, zip, and combine - Kt. Academy
Let's talk about combining two flows into one. There are a few ways to do this. The simplest involves merging the elements from...
Read more >Flow Operators in Assignment Elements - Salesforce Help
Use Assignment element operators to change the value of a selected resource. ... In Flow Builder, we replaced sObject with the Record data...
Read more >Android: Application gets stuck in flow combine and does not ...
I'd suspect that one of your flows is actually empty. Could you ensure that both of them are emitting values?
Read more >Merge operator - IBM
A data flow diagram showing the merge operator being used to merge data from a number of update data sets with data from...
Read more >From Zero To Hero Series ( Kotlin Sequences, Channels ...
Flows have zip and combine operator that combines the corresponding values ... Kotlin coroutines were missing a primitive to represent cold ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
flattenMerge
is in preview, because it has an optionalconcurrency
parameter and we have not decided yet what exactly to do with it and with other “concurrent” operators (see #1147). In particular it means that if you are planning to use the abovemerge
implementation with more than 16 flows, then you should rewrite it like this:The “gotcha” with concurrency limit is a strong motivator for a separate
merge
operator.