Returns a Flow whose values are generated with transform function by combining the most recently emitted values by each flow.
if one flow doesn’t emit resulting flow won’t emit either right?
c
Casey Brooks
02/01/2022, 5:01 PM
combine
is for grouping the results of multiple flows into a single object. To simply create a new Flow that passes through the individual emissions from each one independently,
merge
is the correct operator to use here
m
Marko Novakovic
02/01/2022, 5:09 PM
Copy code
suspend fun main() {
val a = MutableSharedFlow<String>()
val b = MutableSharedFlow<Int>()
a.emit("")
b.emit(1)
merge(a, b)
.collect { println(it) }
}
prints nothing @Casey Brooks. am I doing it wrong?
c
Casey Brooks
02/01/2022, 5:14 PM
By default, `MutableSharedFlow`s will drop emissions if there are no subscribers. You'll need to start