Smorg
11/17/2020, 7:34 PMflow2
based on the condition of an upstream flow flow1
? this is what I have tried but I am not sure if I actually should be doing the tagged line
flow1()
.flatMapLatest { res ->
if(res.conditionIsFalse) {
flowOf() // works but wondering if there is an operator that doesn't require this
} else {
flow2()
}
}
.onEach { flow2Res ->
// do something with flow2Res
}
.launchIn(scope)
wasyl
11/17/2020, 7:43 PMflatMapLatest
is pretty much what you want, you can use emptyFlow()
to not emit anything.Smorg
11/17/2020, 7:44 PMwasyl
11/17/2020, 7:44 PMflatMapMerge
, flatMapConcat
and `flatMapLatest`: the first one will run multiple inner flows simultaneously and emit their values as they come, concat
version will also run inner flows but maintain order in which they were triggered (so concat their emissions), and latest
one will cancel the previous inner flow once the new item is handledSmorg
11/17/2020, 7:48 PMflatMapMerge
doc means for the first time with your explanation 😅