Expand description
Global context state singleton
BlincContextState provides a global singleton for accessing reactive state management and other context-level resources without requiring explicit context parameters.
This enables components to create internal state without leaking implementation details:
ⓘ
// Before: user must manage internal component state
let fruit_open = ctx.use_state_keyed("fruit_open", || false);
cn::select(&fruit, &fruit_open)
// After: component manages internal state via singleton
cn::select(&fruit) // open_state is internal to the component§Initialization
The singleton must be initialized by the app layer before use:
ⓘ
// In WindowedApp::run()
BlincContextState::init(reactive, hooks, dirty_flag);§Usage
Components can access state management via free functions:
ⓘ
use blinc_core::context_state::{use_state_keyed, use_signal_keyed};
// In a component:
let open_state = use_state_keyed("my_component_open", || false);Structs§
- Blinc
Context State - Global context state singleton
- Bounds
- Simple bounds representation for element queries Used by BlincContextState to avoid circular dependencies with blinc_layout
- Hook
State - Stores keyed state across rebuilds
- State
Key - Key for identifying a signal in the keyed state system
Enums§
- Motion
Animation State - Motion animation state for query API
- Update
Category - Update category for element change tracking
Functions§
- query
- Query an element by ID
- query_
motion - Query motion animation state by stable key
- request_
rebuild - Request a UI rebuild
- use_
signal_ keyed - Create a persistent signal that survives across UI rebuilds (keyed)
- use_
state_ keyed - Create a persistent state value that survives across UI rebuilds (keyed)
Type Aliases§
- AnyElement
Registry - Type-erased element registry storage This allows blinc_core to store the registry without depending on blinc_layout
- Bounds
Callback - Callback for getting element bounds by string ID
- Dirty
Flag - Shared dirty flag for triggering UI rebuilds
- Focus
Callback - Callback for focus management Called with Some(id) to focus an element, None to clear focus
- Motion
Cancel Exit Callback - Callback for canceling a motion’s exit animation
- Motion
State Callback - Callback for querying motion animation state by stable key
- Query
Callback - Callback for querying elements by ID Returns the raw node ID (u64) if found, None otherwise
- Recorded
Event Any - Type-erased recorded event for recorder callbacks This avoids circular dependencies by using a boxed Any type
- Recorder
Event Callback - Callback for recording events (mouse, keyboard, scroll, etc.) Events are passed as type-erased Any to avoid circular dependencies
- Recorder
Snapshot Callback - Callback for capturing tree snapshots after each frame
- Recorder
Update Callback - Callback for tracking element updates with category
- Scroll
Callback - Callback for scrolling an element into view
- Shared
Hook State - Shared hook state for the application
- Shared
Reactive Graph - Shared reactive graph for thread-safe access
- Stateful
Callback - Callback for notifying stateful elements of signal changes
- Tree
Snapshot Any - Type-erased tree snapshot for recorder callbacks