Hello, we build SDKs using KMP and one pattern we ...
# multiplatform
j
Hello, we build SDKs using KMP and one pattern we have yet to figure out is how to define common interfaces that interop well with Java. Coroutines get decent interop for objc and swift, especially if using the skie plugin, but not so much with Java. And Java Futures/CompletableFuture are not available in the common sourceset and making them
expect/actual
classes is a big undertaking due to the amount of methods on those types. Does anyone have any recommendations besides just callbacks for java?
t
You could probably write a simple compiler plugin that would generate new functions that return completablefuture/JavaFlow and then hide the original ones from Java
j
KSP or actual Kotlin Compiler Plugin? Do you have any references you can share?
t
Actual Kotlin compiler plugin. Declare it as a new module in your project so that you don’t have to deal with dependencies as much. You can take a look at my Droidcon talks those could give you some guidance. Unfortunately I’m on vacation so I don’t have my laptop on me and can’t send you direct links
👍 1
j
ok thank you.
e
it's out of date but you might be looking for something similar to https://github.com/xebia-functional/AsFuture
j
awesome. thank you.