Hello everyone, so is it possible to access a suspend function value inside another non suspend function. I want to access data store value but its return value is a flow. Is there any way I can do this?
r
Ryan Wong
11/19/2022, 7:47 PM
Any reasons for using
runBlocking
? Have you tried collecting the flow somewhere, so your non suspend function can be called when there is a value emitted?
m
Mahmoud Abdallah
11/21/2022, 6:22 AM
Yes you can. you can use coroutines, launch a coroutine inside your non-suspend function and call your suspend function.
I suggest you read about it.
https://developer.android.com/kotlin/coroutines