I'd like a reliable way to know when the WASM part...
# compose-web
c
I'd like a reliable way to know when the WASM part is ready so I can hide/show a progress indicator when the web page first loads .Is there a documented method or sample for this? I looked at the ImageViewer sample but it's using 1.4.0 and I'm on 1.4.1, so it was hard to follow. I notice it uses this
load.mjs
file and then imports a
<appname>.uninstantiated.mjs
file. I don't see that file generated in my web app static folder, so wondering where does that even come from?
j
Are you making wasm or js apps?
If you are confuse with wasm and js project like me at first time. Now i'm targetting only js for my projects. Because wasm feature need to be enabled in the browser for each user. You can look into my project: https://github.com/JamshedAlamQaderi/portfolio
💯 1
m
I don’t know whether this is still valid because I haven’t updated this sample for a while but at the time I wrote it my main method looked like this and worked:
Copy code
import androidx.compose.material.MaterialTheme
import de.mpmediasoft.polyspiral.gui.PolySpiralApp
import org.jetbrains.skiko.wasm.onWasmReady

fun main() {
    onWasmReady {
        BrowserViewportWindow("PolySpiral - Compose - JS") {
            MaterialTheme {
                PolySpiralApp()
            }
        }
    }
}
The key seems to be the method
onWasmReady
.
m
The janky way to do this is to load a spinner inside a div and then hide that div from within wasm
In general I feel like the wasm compilation/bundle/loading is a dark art
So I'm following this thread to find out as I'd like to do more (e.g, Worker)
c
The janky way to do this is to load a spinner inside a div and then hide that div from within wasm
Oh I totally forgot you could access the DOM in the main method since it’s Kotlin JS. I think I’ll do that instead of rely on the examples I’ve seen in
imageviewer