Skip to content
This repository has been archived by the owner on Aug 10, 2021. It is now read-only.

Suspendable functions not visible in iOS framework #1684

Closed
Marcopohlo opened this issue Jun 12, 2018 · 4 comments
Closed

Suspendable functions not visible in iOS framework #1684

Marcopohlo opened this issue Jun 12, 2018 · 4 comments

Comments

@Marcopohlo
Copy link

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?

@olonho
Copy link
Contributor

olonho commented Jun 13, 2018

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.

@Marcopohlo
Copy link
Author

Marcopohlo commented Jun 13, 2018

@olonho I've been reading more into coroutines and I see why it doesn't work in objc, thank you.

@Thomas-Vos
Copy link
Contributor

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?

@SvyatoslavScherbina
Copy link
Collaborator

SvyatoslavScherbina commented Apr 13, 2020

In Kotlin 1.4 (starting from M2) suspend functions will be available from Swift/Objective-C as functions with completionHandler: callback.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants