Hello,
I have a specific problem with suspendable functions in Kotlin/Native.
So for example function like this will only generate
interface CommandHandler<in T : Command> {
suspend fun handle(command: T)
}
will only generate
@protocol PrefixCommandHandler
@required
@end;
Any way how to fix it?
How do you want it to be exposed in Objective-C? Currently, there's no way to have coroutines in Objective-C or Swift, so exposing suspend functions look tricky.
@olonho I've been reading more into coroutines and I see why it doesn't work in objc, thank you.
How do you want it to be exposed in Objective-C? Currently, there's no way to have coroutines in Objective-C or Swift, so exposing suspend functions look tricky.
@olonho What about exposing it just like in Java? For example this code:
interface MyInterface {
suspend fun getResult(param: String): Boolean
}
would be exposed in Objective-C like the following Kotlin code:
interface MyInterface {
fun getResult(param: String, cont: Continuation<Boolean>)
}
Maybe this can be enabled with an optional compiler flag or something similar?
In Kotlin 1.4 (starting from M2) suspend functions will be available from Swift/Objective-C as functions with completionHandler: callback.
Most helpful comment
In Kotlin 1.4 (starting from M2) suspend functions will be available from Swift/Objective-C as functions with
completionHandler:callback.