Is it possible to invoke a javascript function before Kotlin assigns any classes to it's internal wrappes? Background: matrix.org's olm implementation for javascript uses emscripten wasm and assigns it's classes after calling an init() function. Therefore the kotlin wrappers has unvalid references
t
turansky
08/01/2021, 2:12 PM
You can add injection right in final script
c
CLOVIS
08/01/2021, 2:31 PM
If your project uses an HTML file for startup, you can execute any JS you want before loading the Kotlin file
b
benkuly
08/01/2021, 3:17 PM
Because it's a library injecting sounds very good, but how? Or do you mean manually add it to the script? That sound hacky...
c
CLOVIS
08/01/2021, 5:13 PM
Another solution: use lambdas instead of global variables, this way the references are only created on first access
CLOVIS
08/01/2021, 5:13 PM
Or you might want the ‘initialize globals on first access’ or whatever the option is called (it's one of the options added with IR)
b
benkuly
08/02/2021, 6:24 AM
I don't have global variables. Just classes which are used in the main or test function. In the compiled js code there is stuff like