Vladyslav Sitalo
04/07/2019, 5:08 PMmoduleName
module.exports = {
foo: { /* some code here */ },
C: { /* some code here */ }
}
I can import it to kotlin like this:
@file:JsModule("moduleName")
package ext.jspackage.name
external fun foo()
external class C
The problem with this is that if I want to use that functionality elsewhere in kotlin code - I’ll have to import the functions/objects directly. I.e. like import ext.jspackage.name.foo
. Which is not great, as that name can be generic/etc.
What I want is to recreate experience where I’d call the foo
function with module name prefix - moduleName.foo()
I can’t import modules in Kotlin though, and external
things can’t be defined within non external ones, so I can’t do something like
object moduleName {
external fun foo()
}
Is there a way to accomplish this?Svyatoslav Kuzmich [JB]
04/07/2019, 10:45 PM@JsModule
on external object:
@JsModule("moduleName")
external object moduleName {
fun foo()
}
Svyatoslav Kuzmich [JB]
04/07/2019, 10:51 PMfoo
from your snippet as ext.jspackage.name.foo()
Vladyslav Sitalo
04/07/2019, 11:14 PMVladyslav Sitalo
04/07/2019, 11:16 PM