https://kotlinlang.org logo
#multiplatform
Title
# multiplatform
a

Arthur Brum

03/03/2020, 1:45 PM
Hi, Im getting some problems with kotlin coroutines.. I'm trying to use runBlocking in my common code. And since I don't have a JS target (which is the only target that do not accept runBlocking), it should be possible, right? is there a workaround not being through expect/actual implementations?
🚫 1
s

Sam

03/03/2020, 1:56 PM
No. Just use expect/actual and typealias for the actuals.
a

Arthur Brum

03/03/2020, 2:46 PM
I worked! Thanks!! But I used it like:
Copy code
actual fun <T> runBlocking(block: () -> T): T = kotlinx.coroutines.runBlocking(){block()}
Since iOS doesnt support suspend functions... hope it wont be a problem later =/
s

Sam

03/03/2020, 3:52 PM
iOS supports suspend functions within kotlin. It is only when going from ObjC/Swift -> Kotlin that isn’t supported. For that you should have an alternate function that uses a callback mechanism. That function can call into your suspend function.
👍 1