@John O'Reilly Do you think this library for kmp coroutines is production ready?
5 months ago
@Rick Clephas , as library author, can probably comment in more detail 🙂 , but fwiw seems to work great here. The integration with new swift async/await, AsyncStream etc is really nice ....particularly when mapping to flow in shared code and using appropriate hooks in SwiftUI to invoke async code along with automatic cancellation. you get (which is propagated down to flow)
Personally I'm hoping this library could get integrated in to core Kotlin/Native offering as it, along with use now of new memory model, would make interop so much more seamless (any Jetbrains folks out there that can comment on whether this could happen? 🙂 )
@Rick Clephas I'm curious to know what would it take to create the llvm bridge
5 months ago
Well there is 1 big challenge and that is the absence of kotlinx.coroutines (which is currently used to run/collect suspend functions and flows).
Besides that it should be fairly straightforward (I think). During the ObjC header export coroutines functions/properties should be transformed into lambdas.
After that the invocation of such declarations should should be intercepted and “transformed” into invocations to the wrapper functions (like nativeSuspend).
I think it just depends on the project and your requirements. The goal of KMP-NativeCoroutines is to improve the interop between Kotlin and Swift in terms of async code.
Allowing Swift developers to use Kotlin async code in a "native" way, without making any assumptions about the application architecture. You could even use it with UseCases if you like.