Expand description
Reactive-programming substrate for Frust.
This crate owns the process-wide ReactiveRuntime: a background tokio
runtime, a custom any_spawner executor that routes spawn to that
runtime and spawn_local to a UI-thread local task queue, a swappable
FrameWaker, and the root reactive Owner. It also re-exports the
reactive_graph types the later programming-model tasks build on, and
owns the process-wide deep-link source shells write platform deep links
into (see push_deep_link/deep_links), the process-wide Android
back-press source next to it (see push_back_press/back_presses and
the handles_back flag), and the process-wide desktop menu-activation
source beside those (see push_menu_event/menu_events). A process-wide
signals-dirty flag (ReactiveRuntime::take_signals_dirty), tripped by
TrackedScope’s dirty path, lets a shell ask synchronously and cheaply
once per frame “did any tracked signal change since I last asked” — the
reactive input to the mobile frame gate.
It is a leaf substrate: no winit, no vello/wgpu, no frust-core
dependency. Shells own the wake-up wiring and call ReactiveRuntime::init
(once, on the UI thread) and ReactiveRuntime::pump_local each frame.
Structs§
- Back
Presses - The app-facing back-press read surface (see the module docs). Obtained via
back_presses(frust::back_presses()at the facade). - CanPop
Registration - Proof-of-registration token returned by
set_can_pop_provider. - Deep
Link - One delivered deep link: the raw platform-provided URL/location string
(e.g.
myapp://profile/42), unparsed — turning it into a route is the router layer’s job (the router/deep-link glue), not this crate’s. - Deep
Links - The app-facing deep-link read surface (see the module docs’
app_linkssemantics). Obtained viadeep_links(frust::deep_links()at the facade). - Menu
Event - One delivered menu activation: the id the app gave the item in its
MenuSpec(e.g."file.open"), plus the process-wide sequence number of this activation (see the module docs). The id is passed through verbatim — mapping it to an action is app code’s job, not this crate’s. - Menu
Events - The app-facing menu-activation read surface. Obtained via
menu_events(frust::menu_events()at the facade). - Owner
- A reactive owner, which manages
- Reactive
Runtime - The process-wide reactive runtime. Construct via
ReactiveRuntime::init(once, on the UI thread) and reach later calls viaReactiveRuntime::get. - RwSignal
- An arena-allocated signal that can be read from or written to.
- Tracked
Scope - A reactive observer for a single frame-rebuild pass.
- UseTask
- The handle
use_taskreturns: a read handle to the task’sAsyncValue<T>state plus arestart/refresh trigger.
Enums§
- Async
Value - The exhaustive state of an asynchronously-loaded value.
Functions§
- back_
presses - The current back-press read surface: the live
BackPresses::countsignal. Call from a tracked context (e.g. insideComponent::build, via the facade’sBackHandler) to observe subsequent presses as they arrive. - clear_
can_ pop_ provider - Force-clear the live can-pop provider unconditionally, restoring the
polled
handles_backfallback — a teardown/test hammer, NOT the handler cleanup path. A handler’s cleanup must go through its ownCanPopRegistration::unregisterso a stale registration can never clear a newer one (see the single-registrant invariant onset_can_pop_provider). Idempotent — safe with no provider registered, and it carries no thread constraint (clearing another thread’s empty slot is a harmless no-op). - deep_
links - The current deep-link read surface: a snapshot of
DeepLinks::initialplus the liveDeepLinks::latestsignal. Call from a tracked context (e.g. insideComponent::build) to observe subsequent pushes as they arrive. - handles_
back - Whether the framework wants to consume the next back press. A shell polls
this to decide whether a back press should be routed into the app (
true) or fall through to the platform / activity finish (false, the default until glue publishes otherwise — see the module docs). - menu_
events - The current menu-activation read surface: the live
MenuEvents::latestsignal. Call from a tracked context (e.g. insideComponent::build) to observe subsequent activations as they arrive. - on_
cleanup - Registers a function to be run the next time the current owner is cleaned up.
- provide_
context - Provides a context value of type
Tto the current reactiveOwnerand all of its descendants. This can be accessed usinguse_context. - push_
back_ press - Deliver a platform back press into the process-wide source. Called by a shell (the Android back callback) on the UI thread; app code never calls this directly.
- push_
deep_ link - Deliver a platform deep link (cold-start or warm) into the process-wide source. Called by a shell (the Android/iOS FFI glue) on the UI thread; app code never calls this directly.
- push_
menu_ event - Deliver a native menu activation into the process-wide source. Called by a desktop shell’s per-frame menu pump on the UI thread; app code never calls this directly.
- set_
can_ pop_ provider - Register a live provider
handles_backconsults to answer “would a back press pop?” against the navigator’s CURRENT stack depth, not a rebuild-time snapshot. The facade’sBackHandlerregistersmove || controller.can_pop(), so a press arriving between frames — afterapply_opspublished the new depth but before the next rebuild refreshed the polled flag — is decided correctly instead of falling through to activity finish (see the module docs’ timing section). A registered provider wins overset_handles_back’s flag; the returnedCanPopRegistrationtoken unregisters it scoped-safely. - set_
handles_ back - Publish whether the framework will consume the next back press (see the
module docs’
handles_backsection). The facade’sBackHandlercalls this each rebuild withcontroller.can_pop(); a shell reads the answer viahandles_back. - spawn_
blocking - Runs a one-off, blocking CPU workload on the background runtime’s blocking
thread pool, returning a
JoinHandleto.awaitits result. - use_
context - Extracts a context value of type
Tfrom the reactive system. - use_
task - Runs a fetch, wiring a heavy-work idiom around it.
Type Aliases§
- Frame
Waker - A thread-safe, cheaply-cloneable “wake up and pump soon” callback. On
desktop this is a winit
EventLoopProxysend; on mobile (continuous frame loop) it is a no-op. It must be callable from any thread, since the executor fires it and background tasks may drive signal writes. - Task
Error - The boxed error an
AsyncValue::Errorcarries.Arc-wrapped so a clone of the state is cheap and the error is shareable across the tree.