When I wrap a single value in a flow: Is there a b...
# coroutines
p
When I wrap a single value in a flow: Is there a better way than writing
flow { emit(mySuspendingFunction()) }
?
d
maybe make your function return a flow. The
collect()
will be suspending anyway
d
I dont think there is.
flowOf(x)
probably doesn't work in your case.
But you can make a function yourself of course
g
There is
::mySuspendingFunction.asFlow()
❤️ 1
or (if function requires some arguments), you can just create suspend lambda:
Copy code
suspend { mySuspendingFunction(something) }.asFlow()
the same for non-suspend function
p
Thanks a lot 🙂