Expand description
Reactive data bindings for FrankenTUI.
This module provides change-tracking primitives for reactive UI updates:
Observable: A shared, version-tracked value wrapper with change notification via subscriber callbacks.Subscription: RAII guard that automatically unsubscribes on drop.Computed: A lazily-evaluated, memoized value derived from one or moreObservabledependencies.BatchScope: RAII guard that defers allObservablenotifications until the scope exits, preventing intermediate renders.
§Architecture
Observable<T> uses Rc<RefCell<..>> for single-threaded shared ownership.
Subscribers are stored as Weak function pointers and cleaned up lazily
during notification.
Computed<T> subscribes to its sources via Observable::subscribe(),
marking itself dirty on change. Recomputation is deferred until get().
BatchScope uses a thread-local context to defer notifications. Nested
scopes are supported; only the outermost scope triggers flush.
§Invariants
- Version increments exactly once per mutation that changes the value.
- Subscribers are notified in registration order.
- Setting a value equal to the current value is a no-op (no version bump, no notifications).
- Dropping a
Subscriptionremoves the callback before the next notification cycle. Computed::get()never returns a stale value.- Within a
BatchScope, values are updated immediately but notifications are deferred until the outermost scope exits.
Re-exports§
pub use batch::BatchScope;pub use binding::Binding;pub use binding::BindingScope;pub use binding::TwoWayBinding;pub use binding::bind_mapped;pub use binding::bind_mapped2;pub use binding::bind_observable;pub use computed::Computed;pub use observable::Observable;pub use observable::Subscription;
Modules§
- batch
- Batch update coalescing for [
Observable] notifications. - binding
- Ergonomic binding utilities for connecting
Observablevalues to UI state. - computed
- Lazy computed values that auto-update from
Observabledependencies. - observable
- Observable value wrapper with change notification and version tracking.