Expand description
TUI hooks system — co-located widget state, SDK subscriptions, and animation.
Modeled after React hooks but adapted for Rust’s ownership model and ratatui’s immediate-mode rendering. Three primitives:
use_state<V>(key, default)— Persistent local state across rendersuse_watch(property_handle)— Subscribe to SDK property, return current valueuse_animation(key, active)— Request periodic re-renders when active
§Calling Convention
use_state returns &mut V which borrows &mut self on Hooks.
To avoid borrow conflicts, call hooks in this order:
use_watch— returns ownedOption<V>, borrow released immediatelyuse_animation—&mut selfborrow released immediatelyuse_state— must be called last or in a scoped block
§Frame Lifecycle
hooks.begin_frame() // reset access tracking
terminal.draw(...) // widgets call hooks
hooks.end_frame() // evict unaccessed state + handlesStructs§
- Hooks
- General-purpose hooks system for TUI widget state management.
- Progress
State - Client-side progress interpolation state for a single group.
- Render
Context - Render context passed to all render functions.