tui_dispatch/
lib.rs

1//! tui-dispatch: Centralized state management for Rust TUI apps
2//!
3//! Like Redux/Elm, but for terminals. Components are pure functions of state,
4//! and all state mutations happen through dispatched actions.
5//!
6//! # Example
7//! ```ignore
8//! use tui_dispatch::prelude::*;
9//!
10//! #[derive(Action, Clone, Debug)]
11//! enum MyAction {
12//!     NextItem,
13//!     PrevItem,
14//! }
15//!
16//! #[derive(ComponentId, Clone, Copy, PartialEq, Eq, Hash, Debug)]
17//! enum MyComponentId {
18//!     List,
19//!     Detail,
20//! }
21//! ```
22
23// Re-export everything from core
24pub use tui_dispatch_core::*;
25
26// Re-export derive macros
27pub use tui_dispatch_macros::{Action, BindingContext, ComponentId, DebugState, FeatureFlags};
28
29/// Prelude for convenient imports
30pub mod prelude {
31    // Traits
32    pub use tui_dispatch_core::{
33        Action, ActionCategory, ActionParams, BindingContext, Component, ComponentId,
34    };
35
36    // Event system
37    pub use tui_dispatch_core::{
38        process_raw_event, spawn_event_poller, Event, EventBus, EventContext, EventKind, EventType,
39        NumericComponentId, RawEvent,
40    };
41
42    // Keybindings
43    pub use tui_dispatch_core::{format_key_for_display, parse_key_string, Keybindings};
44
45    // Store
46    pub use tui_dispatch_core::{
47        ComposedMiddleware, LoggingMiddleware, Middleware, NoopMiddleware, Reducer, Store,
48        StoreWithMiddleware,
49    };
50
51    // Effects
52    pub use tui_dispatch_core::{
53        DispatchResult, EffectReducer, EffectStore, EffectStoreWithMiddleware,
54    };
55
56    // Tasks (requires "tasks" feature)
57    #[cfg(feature = "tasks")]
58    pub use tui_dispatch_core::{TaskKey, TaskManager};
59
60    // Subscriptions (requires "subscriptions" feature)
61    #[cfg(feature = "subscriptions")]
62    pub use tui_dispatch_core::{SubKey, Subscriptions};
63
64    // Debug
65    pub use tui_dispatch_core::debug::{
66        ActionLoggerConfig, ActionLoggerMiddleware, DebugFreeze, DebugOverlay, DebugTableBuilder,
67    };
68
69    // Derive macros
70    pub use tui_dispatch_macros::{Action, BindingContext, ComponentId, DebugState, FeatureFlags};
71
72    // Ratatui re-exports
73    pub use tui_dispatch_core::{Color, Frame, Line, Modifier, Rect, Span, Style, Text};
74}