Communities for your favorite technologies. Explore all Collectives
Stack Overflow for Teams is now called Stack Internal. Bring the best of human thought and AI automation together at your work.
Bring the best of human thought and AI automation together at your work. Learn more
Find centralized, trusted content and collaborate around the technologies you use most.
Stack Internal
Knowledge at work
Bring the best of human thought and AI automation together at your work.
I have 2 flows that i would like to merge like i used to do it in RxJava.
In Rx-Java:
Flowable.just(1).mergeWith(Flowable.just(2)).subscribe({ println(it)}) // result: 1, 2
How to replicate that in Kotlin Coroutines ? Thanks in advance.
flattenMerge should provide same behaviour. For example,
flattenMerge
val flow1 = (1..3).asFlow() val flow2 = (4..6).asFlow() flowOf(flow1, flow2).flattenMerge().collect { value -> println("$value") }
Add a comment
Required, but never shown
By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.
Start asking to get answers
Find the answer to your question by asking.
Explore related questions
See similar questions with these tags.