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
xxfast
03/10/2022, 4:06 AM
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
xxfast
03/10/2022, 4:09 AM
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
xxfast
03/10/2022, 4:11 AM
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
andylamax
03/10/2022, 6:11 AM
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
xxfast
03/10/2022, 6:23 AM
ah looks like enum support is on with 1.6.20 which is awesome.