Hello, Our company started using Kotlin Multiplat...
# javascript
m
Hello, Our company started using Kotlin Multiplatform to share libraries between web, mobile and backend. The problem is at least in our experience the development of the actual UI layer on the web takes significantly longer in Kotlin than using TS (just looking at the time to compile it you can see a noticeable difference). Using Kotlin from TS is also a hassle due to suspend functions and conversions. With this in mind, we were thinking to take a similar approach to how mobile development works and separating the actual UI from the logic behind it (similar to MVVM architecture). This way we can write all the business logic in Kotlin and just expose the state and events to TS. 1. What do you think of this idea? 2. Did anybody attempt this? 3. What libraries do you recommend that can easily interact with both Kotlin and Typescript that can handle the state and UI events (eg RxJS)?
👍 2
Maybe even wrapping them inside React hooks... ?
b
That's actually a recommended practice. People only write kotlin ui for android and delegate to native platform layers for ios and web. To pack your kotlin shared module for ts ui app I've written #npm-publish gradle plugin. Just drop in the plugin and it will autoconfigure everything you need to pack your js targets.
🙌 1
a
Wrap everything in hooks, if you are using react. And export that instead
m
@Big Chungus we are already using your Gradle plugin. Great job! Really helps a lot. The problem still remains that JSExport is quite limited so you have to write binds to the actual functions, which is annoying.
@andylamax I think we will do that, at least for the moment. The web app is not that complex so using something like Redux (or ReduxKotlin) seems like overkill...
j
@Mihai Voicescu I'm not sure if it solves your problem, but have you seen https://github.com/deezer/KustomExport ?