https://kotlinlang.org logo
#multiplatform
Title
# multiplatform
h

hallvard

10/15/2018, 7:22 AM
Building for both jvm and js, do the
actual
implementations in js need to have the same package names as in jvm? I have some simple data classes, and accessing them in jvm is a matter of using an import statement in the top of the file and then going directly at them by name, but in the js file I have compiled, it seems I have to go the long way with
com.company.project.dataclass
names. Should I just define aliases right away when
$(document).ready()
?
g

gildor

10/15/2018, 7:34 AM
yes, package name should be the same, otherwise it’s impossible to map expect to actual
h

hallvard

10/15/2018, 7:37 AM
But I guess I could just put the aliases in the js folder, at the no-package base level, and make them point into the package hierarchy, thus making the compiler put the aliases in the js-compiled part of the project and not having to do that myself, every time, on the client side.
g

gildor

10/15/2018, 7:40 AM
Sure, you can have aliases
I just not sure about your use case. Do you want to use them from Js?
h

hallvard

10/15/2018, 7:52 AM
Yes. What I compile in my mpp is basically just static values. I communicate from clientside js with the server through websockets, and the mpp guarantees I use the same keys and values on the client and on the server in the json objects I send back and forth. So the use case is − mostly − just setting
Keys.someKey
to
Values.someValue
. (I also have some functions to construct json objects according to certain constraints, but the irritating part was mainly having to write
com.company.project.Keys.somekey
instead of just
Keys.someKey
.)
6 Views