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

Tony

10/30/2019, 6:04 PM
Can suspend methods on Kotlin Multiplatform be accessed by iOS or Android?
k

Kris Wong

10/30/2019, 6:05 PM
suspend is removed by K/N
t

Tony

10/30/2019, 6:06 PM
Sorry, what is K/N? Kotlin/Native?
k

Kris Wong

10/30/2019, 6:06 PM
yes
t

Tony

10/30/2019, 6:06 PM
thank you!
Is the only way to use the suspend function by putting it in a coroutine launch?
k

Kris Wong

10/30/2019, 6:17 PM
on JVM platforms
t

Tony

10/30/2019, 6:17 PM
jvm and native
k

Kris Wong

10/30/2019, 6:26 PM
how would you use coroutines from iOS?
t

Tony

10/30/2019, 6:27 PM
Make function A() in the kotlin multiplatform common that has a kotlinx coroutines that launches a suspend function. Then on the iOS side, call function A()
k

Kris Wong

10/30/2019, 6:27 PM
are you asking about suspend from your multiplatform library API, or using suspend functions from within your iOS source set?
t

Tony

10/30/2019, 6:30 PM
from the library
but some how call it in the iOS source set
k

Kris Wong

10/30/2019, 6:31 PM
what is it you are trying to accomplish
t

Tony

10/30/2019, 6:31 PM
calling ktor HttpClient get method
k

Kris Wong

10/30/2019, 6:39 PM
have you mentioned it in #ktor ?
t

Tony

10/30/2019, 6:39 PM
I have but no one responded yet. I assume to tried this channel
s

Sam

10/30/2019, 7:02 PM
Kotlin code running in iOS can call suspend functions. Suspend functions are not exposed to ObjC/Swift since there is nothing equivalent in those languages.
t

Tony

10/30/2019, 7:04 PM
Ah! that makes sense. thank you for the clarification
7 Views