Module reactive::signal
Signal<T>: fine-grained reactive state.
The client-side reactivity primitive for WASM-hydrated scx pages (see std/scx/scx.h for the server-side templating half). A Signal owns one value; std/wasm/hydrate.h's DOM bindings subscribe listeners onto it so that set() both updates the value and pushes the change straight to the DOM node(s) that depend on it — SolidJS-style signals, no virtual DOM.
struct Signal<int> count = std::Signal::new(0);
std::signal_subscribe(&count, on_count_changed, (?&Label)&label);
count.set(count.get() + 1); // updates, bumps version, notifies
count.free();
Structs
| SignalSub | One subscriber. Listeners on the same signal carry unrelated context types, so each is stored type-erased; signal_subscribe() only ever pairs a fn void(?&U) with a ?&U, so the erased call is always well-typed (see std/erased.h). |
| Signal |
Functions
| signal_subscribe | Registers listener(userdata) to run on every future set()/notify(). Not called for the initial value — read it directly after subscribing. A free function: U is its own type parameter, and an instance method of a generic struct can't add type parameters of its own yet. |