myanmarking
07/19/2022, 3:20 PMmyanmarking
07/19/2022, 3:20 PMmyanmarking
07/19/2022, 3:21 PMmyanmarking
07/19/2022, 3:22 PMfirstFlow
.flatMapLatest { condition ->
if (condition) {
flowOf(true)
} else {
secondFlow
.flatMapLatest { condition ->
if (condition) {
flowOf(true)
} else {
thirdFlow
}
}
}
}
curioustechizen
07/19/2022, 3:22 PMmyanmarking
07/19/2022, 3:22 PMmyanmarking
07/19/2022, 3:23 PMRobert Williams
07/19/2022, 3:44 PMfirstFlow
emits again once secondFlow
is started you need to cancel secondFlow
and maybe restart it (if still false)?Robert Williams
07/19/2022, 3:46 PMlouiscad
07/19/2022, 4:14 PMcombine
but I'm not sure I understood what you want to do.myanmarking
07/19/2022, 4:23 PMlouiscad
07/19/2022, 4:24 PMlouiscad
07/19/2022, 4:24 PMflowA.first() || flowB.first() || flowC.first()
myanmarking
07/19/2022, 4:26 PMmyanmarking
07/19/2022, 4:26 PMmyanmarking
07/19/2022, 4:27 PMRobert Williams
07/19/2022, 4:29 PMmerge
is more appropriate than combine
?Robert Williams
07/19/2022, 4:30 PMmyanmarking
07/19/2022, 4:31 PMlouiscad
07/19/2022, 4:32 PMraceOf({
flowA.first { it }
}, {
flowB.first { it }
}, {
flowC.first { it }
})
With raceOf
as defined at the end of this article: https://blog.louiscad.com/coroutines-racing-why-and-howmyanmarking
07/19/2022, 4:35 PMStephen Edwards
07/19/2022, 8:13 PMmerge
makes sense but I don't understand your point here:
but it collect the three needlesslly
merge
would still collect all 3 so it can emit the latest value from any of them.Stephen Edwards
07/19/2022, 8:15 PMnatario1
07/19/2022, 10:06 PMRobert Williams
07/20/2022, 9:50 AMRobert Williams
07/20/2022, 9:50 AMRobert Williams
07/20/2022, 9:51 AMRobert Williams
07/20/2022, 9:51 AMmyanmarking
07/20/2022, 9:51 AMRobert Williams
07/20/2022, 9:53 AMmerge().filter(it).first()
myanmarking
07/20/2022, 9:53 AMmyanmarking
07/20/2022, 9:53 AMmyanmarking
07/20/2022, 9:54 AMmyanmarking
07/20/2022, 9:54 AMRobert Williams
07/20/2022, 10:01 AMRobert Williams
07/20/2022, 10:03 AMRobert Williams
07/20/2022, 10:05 AMlouiscad
07/20/2022, 1:29 PM