Skip to main content

Module reactive

Module reactive 

Source
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 changes
  • ReactiveChange — records a single field change with old/new values
  • ReactiveCtx — context passed to setters, accumulates changes
  • ReactiveWidget — 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§

ReactiveChange
Records a single field change during an event dispatch cycle.
ReactiveCtx
Context passed to reactive setters. Records changes and provides node identity.
ReactiveFieldDescriptor
Static descriptor for a single reactive field on a widget.
ReactiveFlags
Flags controlling what happens when a reactive field changes.
ReactivePhaseResult
Outcome of running the reactive phase for a single widget.
RuntimeReactiveEntry
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§

ReactiveWidget
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.