Damiano Giusti
12/13/2021, 2:34 PMnative-mt
onehfhbd
12/13/2021, 2:44 PMnative-mt
version, which will be published after 1.6.0
official release.
There is wip to support non native-mt version: https://github.com/ktorio/ktor/tree/e5l/coroutinesDamiano Giusti
12/14/2021, 8:11 AM1.5.2-native-mt
, and now the only limitation on iOS is that suspend functions must be called from the main threadrudolf.hladik
12/14/2021, 10:32 AMkotlin = "1.6.0"
coroutines = "1.6.0-RC"
ktorVer = "1.6.2-native-mm-eap-196"
with
# enable new native memory model
kotlin.native.binary.memoryModel=experimental
kotlin.native.binary.freezing=disabled
and it works all fineJohn O'Reilly
12/14/2021, 10:33 AMDamiano Giusti
12/14/2021, 11:13 AMCalling Kotlin suspend functions from Swift/Objective-C is currently supported only on main thread
error with this setup? I just tried with your configuration but coroutines 1.6.0-RC2 and I’m still getting the error.
Btw Kotlin 1.6.10 has just been released 😄hfhbd
12/14/2021, 12:44 PMrudolf.hladik
12/15/2021, 11:00 AM0.2.0-SNAPSHOT-MM
. But you can basically use something like this
fun <T> execute(scope: CoroutineScope, suspendBlock: suspend ()-> T, onSuccess: (T) -> Unit, onError: (Throwable) -> Unit): Job {
// launch on main dispatcher
return scope.launch {
runCatching {
suspendBlock() // suspend block can be called on different dispatcher
}.fold(onSuccess,onError) // onSuccess, onError called on main
}
}