short of writing my own extension function, is the...
# coroutines
w
short of writing my own extension function, is there any more concise way of writing
Copy code
flow {
    emit(suspendFunction())
}
I know I could use
flowOf(…)
but the call site is not in a suspend function already
a
Something like
::suspendFunction.asFlow()
?
🆒 5
w
woah didn’t know that existed
neat
m
Somewhat related, for suspending functions (or lambdas) that return a
Flow
I use these convenience functions:
Copy code
fun <T> suspendAsFlow(flowLambda: suspend () -> Flow<T>) = flowLambda.asFlow()

fun <T> (suspend () -> Flow<T>).asFlow(): Flow<T> = flow {
    val flow = this@asFlow()
    emitAll(flow)
}
u
the .asFlow is useless if you have external params. I really wish the library provided this. Everybody then calls it differently, mine is
simpleFlow { }