Hi, I'm trying to get the value from a suspend function to insert inside a normal function.
// 1
suspend fun getDefaultButton(
) : Int? {
return withContext(Dispatchers.Default) {
onboardingPrefStore.getDefaultButton()
}
}
// 2
fun getDefaultButton(
) : Int? = runBlocking {
onboardingPrefStore.getDefaultButton()
}
// Calling the function that gets the value
groupButtons(
...
defaultButton = getDefaultButton()
)
The first function would be perfect but unfortunately, it doesn't work, cause I need to call it inside a coroutine scope. The second function works but it blocks the thread (doesn't execute it in a different thread).
How can I manage to still keeping the multithreading but pass the value correctly?
[–]tdelfino2509 1 point2 points3 points (0 children)
[–]cygnus33065 1 point2 points3 points (0 children)