Expand description
Reactive attribute system for textual-rs.
Provides automatic change detection, repaint/layout invalidation, and
watcher dispatch for widget fields annotated with #[reactive] or #[var].
§Overview
This module defines the core types that power the reactive system:
ReactiveFlags— controls what happens when a reactive field changesReactiveChange— records a single field change with old/new valuesReactiveCtx— context passed to setters, accumulates changesReactiveWidget— trait implemented by#[derive(Reactive)]
§Usage
ⓘ
use textual_macros::Reactive;
#[derive(Reactive)]
struct MyWidget {
#[reactive]
label: String,
#[reactive(layout)]
size: usize,
#[var]
counter: u32,
}Structs§
- Reactive
Change - Records a single field change during an event dispatch cycle.
- Reactive
Ctx - Context passed to reactive setters. Records changes and provides node identity.
- Reactive
Field Descriptor - Static descriptor for a single reactive field on a widget.
- Reactive
Flags - Flags controlling what happens when a reactive field changes.
- Reactive
Phase Result - Outcome of running the reactive phase for a single widget.
- Runtime
Reactive Entry - Queued reactive work unit drained by the runtime event loop.
Constants§
- MAX_
REACTIVE_ ITERATIONS - Maximum number of reactive iterations before the runtime considers a cycle and stops processing. Protects against infinite watcher loops where one watcher’s side-effect triggers another change ad infinitum.
Traits§
- Reactive
Widget - Trait implemented by
#[derive(Reactive)]structs.
Functions§
- enqueue_
runtime_ reactive_ entry - Enqueue a reactive work item to be processed in the runtime reactive phase.
- run_
reactive_ phase - Run the reactive phase for a single widget: drain changes, call watchers, and repeat until no new changes are produced (or cycle limit is hit).
- run_
reactive_ phase_ with_ dispatch - Run the reactive phase with a custom dispatch function.
- take_
runtime_ reactive_ entries - Drain all queued runtime reactive work items.