Hey did somebody had luck to integrate KotlinJs wi...
# javascript
m
Hey did somebody had luck to integrate KotlinJs with WASM?
b
Haven't actually tried it myself, but in theory this should work: 1. Use @JsExport in your kjs code for the stuff you want visible to wasm 2. Attach your kjs output as wasm sourceSet resources 3. Have your wasm index.html load your js output file via relative path from wasm resources root 4. Interract with js code from wasm like this and then this
m
Actually my usecase goes the other way around...calling WASM from JS...since WASM is loaded asynchronous (as Promise)...I do not get to work properly with the rest of my stuff...
But thx anyways!
b
Ah, not THAT I haven't tried even with deprecated K/WASM32
However this should be applicable, because at the point you're calling WASM from your js output it has no clue that it was (or was not) built from kotlin
To work with promises, either enter the good old callback hell or use suspend functions with kotlinx.coroutines Promise extensions
m
Indeed...and it makes everything super complex since as you can imagine...However Compose has this little function and I was wondering if somebody did something similar but for modules
b
I'm pretty sure that's just a good old promise with your lambda being registered as a callback. Pretty easy to reproduce with kotlin.js.Promise