Skip to main content

Crate telar_reactive_core

Crate telar_reactive_core 

Source
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 let the reader captures.
Emitter
The worker’s handle to a spawn_stream, for posting items back to the UI thread. Send and cloneable, so the work can hand it to nested helpers or a callback-driven library.
FlushNotifyHandle
Memo
ReadSignal
RwSignal
SurfaceEnterGuard
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.
SurfaceHandle
Identifies which surface (window / layer-surface) a reactive effect belongs to. It is a cheap Copy id: 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 cancel when 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 surface was 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 a SurfaceEnterGuard that restores the previous world on drop. The higher-level Surface layer installs this; reactive-core only knows how to call it. Without a hook, SurfaceHandle::enter is 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 work on a background thread, handing it an Emitter, and runs on_item on this thread for every item it emits — in order, during the frames that follow. on_end runs once the worker returns.
spawn_task
Runs work on a background thread and on_done with its result on this thread, during a later frame’s drain_tasks.