Reservoir
Overview
Reservoir is a Redux-inspired state management library in the Mississippi framework. It manages local feature states using a dispatch pipeline defined by IStore and inspired by Redux and Flux.
Use this page as an orientation page for Reservoir. Use the child pages for specific contracts, task guidance, and testing details.
Core Components
Reservoir consists of six core components that work together to manage application state:
| Component | Purpose |
|---|---|
| Action | Records that describe what happened or what the user intends (actions should be immutable) (IAction) |
| Action Reducer | Pure functions that transform state based on actions (IActionReducer) |
| Selector | Pure functions that derive computed values from state with optional memoization (Selectors) |
| Action Effect | Handlers for async side effects (API calls, navigation, timers) (IActionEffect) |
| Feature State | State slices representing distinct areas of the application (feature states should be immutable) (IFeatureState) |
| Store | Central container that manages feature states and coordinates dispatch (IStore) |
How It Works
When a user interaction or system event occurs, an action is dispatched to the store. The store processes the action through a pipeline:
-
Middleware Pipeline: Actions pass through registered
IMiddlewarecomponents for logging, analytics, or transformation. -
Store Events: The store emits
StoreEventBaseevents throughIStore.StoreEvents, enabling external integrations (like DevTools) to observe activity via composition. -
Reducers Execute: The store invokes
IRootReducer<TState>for each feature state. Matching reducers produce new immutable state. -
Listeners Notified: Subscribed listeners (via
Store.Subscribe()) are notified synchronously after the action is processed. -
Effects Triggered:
IRootActionEffect<TState>dispatches to matching effects asynchronously. Effects can yield new actions, continuing the cycle.
Why Use Reservoir
- reducers keep synchronous state transitions explicit
- effects isolate asynchronous side effects
- selectors keep derived logic reusable and testable
- middleware handles cross-cutting behavior without moving that logic into components
Built-In Surfaces
Reservoir includes documentation for both its core state-management pieces and the Blazor-specific integration surfaces that sit on top of them.
Use the child pages for details on:
- actions, reducers, effects, selectors, feature state, store, and middleware
StoreComponentand the built-in Blazor features- testing patterns and DevTools integration
Learn More
- Actions - Define and organize actions
- Reducers - Write pure reducer functions
- Effects - Handle async side effects
- Feature State - Design modular state slices
- Store - See the store contract and dispatch behavior
- Middleware - Handle cross-cutting concerns
- StoreComponent - Integrate Reservoir with Blazor components
- Selectors - Derive computed values from state
- Built-in Navigation - Look up the built-in navigation feature
- Built-in Lifecycle - Look up the built-in lifecycle feature
- DevTools - Enable Redux DevTools integration
- Testing - Test reducers, effects, selectors, and built-in features