https://kotlinlang.org logo
#getting-started
Title
# getting-started
m

Marko Kunic

11/03/2021, 4:41 PM
a library I am using has a suspend function, I am wondering how can I get a value out of that function without actually making my function suspended?
j

Joffrey

11/03/2021, 4:42 PM
If you're on the JVM or Native, you can block the current thread while you wait for the suspend function call:
Copy code
val result = runBlocking { suspendFunCall() }
m

Marko Kunic

11/03/2021, 4:44 PM
so return value from
suspendFunCall
would be set in result? and it would block the thread until it gets it back?
👌 1
yep, that is it, ty
j

Joffrey

11/04/2021, 9:59 AM
Yes, sorry for the delay, I was afk. I guess you figured it out 😅
3 Views