Marko Novakovic
02/01/2022, 4:54 PMFlow
that emits when either SharedFlow
emits?FunkyMuse
02/01/2022, 4:56 PMMarko Novakovic
02/01/2022, 5:01 PMReturns 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?Casey Brooks
02/01/2022, 5:01 PMcombine
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 hereMarko Novakovic
02/01/2022, 5:09 PMsuspend 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?Casey Brooks
02/01/2022, 5:14 PMcollect { }
-ing before calling .emit
on either of the original flowsMarko Novakovic
02/01/2022, 5:27 PM