Any experiences using KMM to share code between an...
# multiplatform
d
Any experiences using KMM to share code between an Android Native project and a React Native project? I imagine this can be done by transpiling module(s) to NPM-module via Kotlin/JS, but not sure if any required bindings present a barrier. (Disclaimer: Yes I would rather use KMM for the whole project, but that's just not a situation I can change, however this code-sharing route may be viable).
x
I’ve done this with pure javascript react app (not kotlin-wrappers) w/ kotlin-sources being consumed as a pure-js libary published via npm-publish plugin (thanks @Big Chungus). This previous thread was about how we can consume a
StateFlow<State>
directly as a react-hook
Although, I should say that
@JsExport
limitations make this experience very undesirable. You need may need to do some state-model transformations from kt-to-js and vice-versa, mainly because
@JsExport
sucks
Admittedly i haven’t done this for React Native; but if we go with their motto “Learn once, write anywhere” this shouldn’t be that far off
a
We are currently doing this with React Native @JsExport got some amazing love in kotlin 1.6.20 which made the whole process tolerable Collections are still a pain to use in JS, so I have written a wrapper that makes them usable But once all is set up its a blast
👀 1
😮 1
x
ah looks like enum support is on with 1.6.20 which is awesome.
👍 1