myanmarking
01/02/2020, 4:42 PMstorage.findXXX(userId)
.flatMapLatest {
if(it == null){
flowOf(
storage.findYYY(userId)
)
} else{
flowOf(it)
}
}
Zach Klippenstein (he/him) [MOD]
01/02/2020, 4:44 PMflowOf
, since there's only one value in either case. Presumably your actual code has multiple values?myanmarking
01/02/2020, 4:45 PMZach Klippenstein (he/him) [MOD]
01/02/2020, 4:47 PMtransform
operator:
.transform {
if (it == null) {
emit(…)
emit(…)
// or
emitAll(otherFlow)
} else {
emit(it)
}
See https://kotlinlang.org/docs/reference/coroutines/flow.html#transform-operatormyanmarking
01/02/2020, 4:47 PMPaul Woitaschek
01/02/2020, 6:03 PM