comlink icon indicating copy to clipboard operation
comlink copied to clipboard

[Feature Request] Kotlin/JS support

Open Jolanrensen opened this issue 5 years ago • 2 comments

Hi, I'm just gonna put this here. I'm not sure if it's even possible (my brain broke trying to convert / adapt comlink to work with Kotlin JS), but it would be awesome if it could work!

Kotlin is great for multihtreading using coroutines, however, multithreading in JavaScript is limited to workers. A library like comlink or something comparable would be a really powerful tool to enhance Kotlin JS. I'm especially intrigued by the idea of accessing objects from multiple threads, just like in for instance the JVM. If combined with inline workers (like how https://github.com/developit/greenlet does it) and constrained by interfaces, I think something like Comlink could really boost the adaption of Kotlin JS.

Jolanrensen avatar Jan 31 '20 17:01 Jolanrensen

I've been prototyping this idea for an internal project of mine, so to a degree I know it's possible.

Edit: I re-read your description and your context is different than mine. What I'm trying to do is have JS interop with Kotlin (JVM) given a Chrome WebView on Android: Comlink endpoint on the JS side, and Comlink compatible endpoint on the WebView that exposes to Kotlin.

jccr avatar Feb 07 '20 18:02 jccr

Right, yeah that's different. Probably easier, as the JVM already offers threading. However, while you can do some Javafx stuff in browsers, I think JavaScript is still faster and better suited to modern day browsers (correct me if I'm wrong). It just needs, imo, a bit of kotlin and multithreading to be more enjoyable and useful.

Jolanrensen avatar Feb 08 '20 14:02 Jolanrensen