Expand description
Factory functions (signal, effect, memo) create
nodes in the reactive graph. Struct constructors (Runtime::new, etc.) own
their state. Free functions (batch, set_flush_notify) operate on the
thread-local runtime.
Modules§
- reentry
- Naming both sides when a thread-local world is reached while it is already borrowed.
Macros§
- surface_
local - Generates a swappable per-surface thread-local plus its
Context/Guard. See the module docs.
Structs§
- Effect
- A live subscription. Dropping it deregisters the effect, so the closure runs once and never again — which
looks exactly like a working binding until the value it derives is expected to move. Bind it to something
that lives as long as the work should: a struct field, a returned value, or a
letthe reader captures. - Emitter
- The worker’s handle to a
spawn_stream, for posting items back to the UI thread.Sendand cloneable, so the work can hand it to nested helpers or a callback-driven library. - Flush
Notify Handle - Memo
- Read
Signal - RwSignal
- Surface
Enter Guard - RAII guard restoring the surface context that was active before
SurfaceHandle::enter. Produced by the installed hook (carrying a restore closure) or as an inert no-op. - Surface
Handle - Identifies which surface (window / layer-surface) a reactive effect belongs to. It is a cheap
Copyid: the reactive runtime stamps one onto every effect at registration and re-enters that surface’s context before running the effect during a flush, so an effect owned by surface A resolves its layout/overlay/focus world against A even when a signal set from surface B triggers it (the “owner scope” model of Solid/Floem). - Task
- A spawned task or stream. Dropping it detaches — the work keeps running and its callback keeps firing.
Keep it to
cancelwhen whatever the callback would write is going away.
Traits§
- Source
- Anything a derivation — or a widget — can read reactively: either handle on a signal, or a value already derived once.
Functions§
- batch
- begin_
batch - cancel_
tasks_ for - Cancels everything spawned while
surfacewas the active one, discarding their callbacks and telling stream workers to stop. Use it when a surface goes away, so work started for it cannot write into the world it left. - current_
surface - The surface an effect registered right now would be owned by.
- derive
- A value derived from another, recomputed when its source moves.
- derive_
pair - [
derive] over two sources, recomputed when either moves — a label that reads a level and whether it is charging, and has to follow both. - drain_
tasks - Runs the callbacks for every value posted since the last call. The runner calls this once per frame, on
the UI thread, before
App::on_frame. - effect
- end_
batch - memo
- reset_
runtime - reset_
tasks - Stops the worker pool and drops every pending callback. Called before a hot-reload dylib is closed: its threads are parked in, and its callbacks are made of, code that is about to be unmapped.
- set_
current_ surface - Sets the active surface, returning the previous one (so the caller can restore it). The surface layer’s
enter hook uses this; app code should go through
Surface::enter. - set_
flush_ notify - set_
surface_ enter_ hook - Installs the thread’s surface-context hook. Given a
SurfaceHandle, it must activate that surface’s full per-surface world (the reactive current-surface plus the layout/overlay/focus/… thread-locals) and return aSurfaceEnterGuardthat restores the previous world on drop. The higher-levelSurfacelayer installs this; reactive-core only knows how to call it. Without a hook,SurfaceHandle::enteris a no-op — which is exactly right for single-window apps that never install one. - set_
task_ waker - Installs the process-global “wake the UI loop” used after a task posts a value. The runner passes the
same wake an app gets from
AppCtx::redraw_waker. - signal
- spawn_
stream - Runs
workon a background thread, handing it anEmitter, and runson_itemon this thread for every item it emits — in order, during the frames that follow.on_endruns once the worker returns. - spawn_
task - Runs
workon a background thread andon_donewith its result on this thread, during a later frame’sdrain_tasks.