Cross Platform Interop Between Kotlin JS And Kotlin JVM


#1

Is there a system in place to provide basic interop between Kotlin JS and Kotlin JVM for Kotlin 1.1?

One scenario where interop is needed would be in a basic web app where both the back end (JVM platform via a basic micro web framework/lib/toolkit - eg Vert.x) and front end (JS platform using just JQuery for high level DOM access/manipulation) parts are developed in Kotlin. Both parts need to communicate with each other through some message passing mechanism (may pass through some primitive data and may resemble an API).


#2

kotlin team announced some plans about general serialization framework api but nothing specific yet.
For now I would suggest using json serialization on server side and dynamic vars on client side.
If you are using jquery on client it will be small scale part anyway and dynamic for everything won’t hurt.


#3

Btw If you can manage to omit things like @JsonProperty annotations altogether in server code it will be possible to share dto’s. Looks like latest beta of kotlin js compiler skips getter/setter generation in js code for simple properties so names do match in js code to Jvm property names.


#4

@Konstantin-Khvan - Presumably when you mention “@JsonProperty” you are referring to the use of the Jackson library. So in that case provided a web server is used along with a REST framework/library on the JVM side then the JS side can communicate with it. Not an ideal solution since REST APIs aren’t type safe and don’t come with any decent built in security.


#5

Would be great if someone on the Kotlin team could provide specific information on the serialisation framework. What use cases is the serialisation framework targeting?


#6

As it turns out REST APIs can be secured so that is a possible option.