Update kjol website with C documentation
This commit is contained in:
@@ -56,6 +56,7 @@ func Hydrate(component func() *vdom.VNode) {
|
||||
finish(root)
|
||||
}
|
||||
|
||||
// finish wires the hot-swap teardown hook. It RETURNS — see Wait.
|
||||
func finish(root js.Value) {
|
||||
// Allow a JS loader to tear this instance down before an in-place hot swap:
|
||||
// snapshot signal state (so the next instance restores it), then clear #app.
|
||||
@@ -65,7 +66,29 @@ func finish(root js.Value) {
|
||||
root.Set("innerHTML", "")
|
||||
return nil
|
||||
}))
|
||||
select {} // keep the runtime alive for event callbacks
|
||||
}
|
||||
|
||||
// Wait blocks forever, keeping the Go runtime alive so its event callbacks can fire.
|
||||
//
|
||||
// It is the LAST line of main, and it is not optional: a Go/wasm program whose main
|
||||
// returns is a dead program, and every handler you registered panics with "Go program has
|
||||
// already exited" the first time it is touched.
|
||||
//
|
||||
// This used to be the last line of Run and Hydrate instead — a `select {}` buried inside
|
||||
// them. That made both of them functions that never return, which is not what they look
|
||||
// like, and it quietly turned everything written after the mount call into dead code:
|
||||
//
|
||||
// wasmruntime.Hydrate(render)
|
||||
// app.Theme.Init() // never ran. Not once.
|
||||
//
|
||||
// The theme controller sat there for the life of the project not knowing what theme the
|
||||
// page was in, so the first click of the switch did nothing at all. Anything you have to
|
||||
// do AFTER the first render — adopt a stored preference, start a poller, measure the
|
||||
// page — hits the same wall.
|
||||
//
|
||||
// So: mounting mounts, and blocking is its own line, where you can see it.
|
||||
func Wait() {
|
||||
select {}
|
||||
}
|
||||
|
||||
func scheduleRender() {
|
||||
|
||||
Reference in New Issue
Block a user