William Reed
07/02/2021, 12:05 PMflow {
emit(suspendFunction())
}
I know I could use flowOf(…)
but the call site is not in a suspend function alreadyalexandrepiveteau
07/02/2021, 1:22 PM::suspendFunction.asFlow()
?William Reed
07/02/2021, 1:26 PMWilliam Reed
07/02/2021, 1:26 PMMark
07/04/2021, 3:31 AMFlow
I use these convenience functions:
fun <T> suspendAsFlow(flowLambda: suspend () -> Flow<T>) = flowLambda.asFlow()
fun <T> (suspend () -> Flow<T>).asFlow(): Flow<T> = flow {
val flow = this@asFlow()
emitAll(flow)
}
ursus
07/04/2021, 12:15 PMsimpleFlow { }