leptos_state/lib.rs
1//! # Leptos State Management Library
2//!
3//! A state management library for Leptos applications inspired by Zustand's simplicity
4//! and XState's state machine capabilities.
5//!
6//! ## Features
7//!
8//! - **Store Management**: Zustand-inspired stores with reactive updates
9//! - **State Machines**: XState-inspired finite state machines
10//! - **Leptos Integration**: First-class support for Leptos reactive primitives
11//! - **TypeScript-like DX**: Ergonomic APIs with strong type safety
12//!
13//! ## Quick Start
14//!
15//! ```rust,ignore
16//! use leptos::*;
17//! use leptos_state::*;
18//!
19//! // Create a store
20//! #[derive(Clone, PartialEq)]
21//! struct AppState {
22//! count: i32,
23//! }
24//!
25//! create_store!(AppStore, AppState, AppState { count: 0 });
26//!
27//! // Use in components
28//! #[component]
29//! fn Counter() -> impl IntoView {
30//! let (state, set_state) = use_store::<AppStore>();
31//!
32//! view! {
33//! <button on:click=move |_| set_state.update(|s| s.count += 1)>
34//! "Count: " {move || state.get().count}
35//! </button>
36//! }
37//! }
38//! ```
39
40pub mod compat;
41pub mod hooks;
42pub mod machine;
43pub mod store;
44pub mod utils;
45
46// Re-export commonly used items
47// Store types
48pub use store::{
49 create_computed, provide_store, use_store_slice, LoggerMiddleware, MiddlewareChain, Store,
50 StoreContext, StoreSlice, ValidationMiddleware,
51};
52// Machine types
53pub use machine::{Machine, MachineBuilder, MachineState, StateMachine};
54// Hook types
55pub use hooks::{use_machine, use_machine_history, use_store};
56// Utility types
57pub use utils::{LogLevel, StateError, StateResult};
58// Compatibility layer
59pub use compat::*;