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

felislynx

06/03/2020, 7:19 AM
Hi, i would like to ask how to handle Coroutines on ios side. In my shared library api calls look like this
Copy code
fun apiCall() = GlobalScope.async(ApplicationDispatcher) {..}
so in Android code i can do val returnValue = apiCall().await() how to handle same flow in iOS ? I see that return type for this function is
Copy code
Kotlinx_coroutines_coreDeferred
but there is no await() function available
r

russhwolf

06/03/2020, 12:43 PM
You can't call suspend functions from Swift. The typical strategy I've seen for handling this is to consume the suspend function from Kotlin/Native, possibly using a lambda or other callback that you pass from Swift. In 1.4 (starting with M2) the compiler will do this for you and generate a callback interface that you can use from Swift without you needing to do extra work
9 Views