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::reducer_compose;
25pub use tui_dispatch_core::*;
26
27// Debug utilities
28pub use tui_dispatch_debug::debug;
29
30// Re-export derive macros
31pub use tui_dispatch_macros::{Action, BindingContext, ComponentId, DebugState, FeatureFlags};
32
33/// Prelude for convenient imports
34pub mod prelude {
35    // Traits
36    pub use tui_dispatch_core::{
37        Action, ActionCategory, ActionParams, BindingContext, Component, ComponentId,
38    };
39
40    // Event system
41    pub use tui_dispatch_core::{
42        process_raw_event, spawn_event_poller, Event, EventBus, EventContext, EventKind, EventType,
43        NumericComponentId, RawEvent,
44    };
45
46    // Keybindings
47    pub use tui_dispatch_core::{format_key_for_display, parse_key_string, Keybindings};
48
49    // Store
50    pub use tui_dispatch_core::reducer_compose;
51    pub use tui_dispatch_core::{
52        ComposedMiddleware, LoggingMiddleware, Middleware, NoopMiddleware, Reducer, Store,
53        StoreWithMiddleware,
54    };
55
56    // Effects
57    pub use tui_dispatch_core::{
58        DispatchResult, EffectReducer, EffectStore, EffectStoreWithMiddleware,
59    };
60
61    // Runtime helpers
62    pub use tui_dispatch_core::{
63        DispatchRuntime, DispatchStore, EffectContext, EffectRuntime, EffectStoreLike,
64        EventOutcome, PollerConfig, RenderContext,
65    };
66
67    // Tasks (requires "tasks" feature)
68    #[cfg(feature = "tasks")]
69    pub use tui_dispatch_core::{TaskKey, TaskManager};
70
71    // Subscriptions (requires "subscriptions" feature)
72    #[cfg(feature = "subscriptions")]
73    pub use tui_dispatch_core::{SubKey, Subscriptions};
74
75    // Debug
76    pub use tui_dispatch_debug::debug::{
77        ActionLoggerConfig, ActionLoggerMiddleware, DebugFreeze, DebugOverlay, DebugTableBuilder,
78    };
79
80    // Derive macros
81    pub use tui_dispatch_macros::{Action, BindingContext, ComponentId, DebugState, FeatureFlags};
82
83    // Ratatui re-exports
84    pub use tui_dispatch_core::{Color, Frame, Line, Modifier, Rect, Span, Style, Text};
85}