CLOVIS
08/22/2021, 2:48 PMval flow = myFlow()
flow.collect {
if (it is Success) {
// I found the value I was waiting for,
// stop collecting values and go back to executing the function
}
}
diesieben07
08/22/2021, 2:57 PMflow.transformWhile { it ->
emit(it)
return it !is Success
}.collect { ... }
CLOVIS
08/22/2021, 3:02 PMdiesieben07
08/22/2021, 3:04 PMSuccess
value in collect
you can also use takeWhile { it !is Success }
ephemient
08/23/2021, 4:02 AMreturn@transformWhile
thereflow.firstOrNull { it is Success } // doesn't cast to Success?
flow.filterIsInstance<Success>().firstOrNull() // does
flow.any { it is Success }
CLOVIS
08/23/2021, 7:43 AMfirst
any
etc where available on flow