plushie/runtime_web
JavaScript runtime: callback-driven Elm update loop.
This is the JS-target equivalent of runtime.gleam (which uses
OTP actors). It manages the app model, executes the update/view
cycle, diffs trees, sends patches to the WASM bridge, and handles
command execution and subscription lifecycle.
State is stored in a mutable JS object via FFI. The update cycle
is synchronous (no process boundaries). Event coalescing uses
queueMicrotask to batch high-frequency events.
Architecture
The JS runtime reuses the same pure functions as the BEAM runtime:
app.get_update(app)(model, msg)for the update steptree.normalize_view(raw_tree, registry, memo_cache)for scoped IDs, widget registry accumulation, and explicit-window validationtree.diff(old, new)for incremental patchingprotocol/encode(JSON path) for wire serialization
What differs is the concurrency model: instead of OTP actors and process messages, the JS runtime uses callbacks, Promises, and setTimeout/setInterval for async work. Those callbacks enter through the JS handle’s dispatch queue, so a callback that fires while an update is running is processed after the current update/render cycle finishes.
Types
pub type JsRuntimeTarget {
JsRuntimeTarget
}
Constructors
-
JsRuntimeTarget