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:

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
Search Document