Allan Wang
09/27/2020, 10:16 AMwithTimeoutOrNull(time) {
flow.collect { ... }
}
Is there a way to do this in the middle of the flow, such that the function still returns Flow<T>
?coroutinedispatcher
09/27/2020, 10:36 AMAllan Wang
09/27/2020, 1:53 PMFlow<T>
for other calls, as I won’t be collecting values yetbezrukov
09/27/2020, 2:20 PMfun <T> Flow<T>.withTimeout(timeMillis: Long): Flow<T> = flow {
withTimeoutOrNull(timeMillis) {
collect {
emit(it)
}
}
}
in this case you literally do this in the middle of the flowAllan Wang
09/27/2020, 2:45 PM