Hi, Im getting some problems with kotlin coroutine...
# multiplatform
a
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
No. Just use expect/actual and typealias for the actuals.
a
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
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