Skip to main content

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:

ComponentPurpose
ActionRecords that describe what happened or what the user intends (actions should be immutable) (IAction)
Action ReducerPure functions that transform state based on actions (IActionReducer)
SelectorPure functions that derive computed values from state with optional memoization (Selectors)
Action EffectHandlers for async side effects (API calls, navigation, timers) (IActionEffect)
Feature StateState slices representing distinct areas of the application (feature states should be immutable) (IFeatureState)
StoreCentral 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:

  1. Action Dispatched: An IAction is dispatched to the IStore.

  2. Middleware Pipeline: Actions pass through registered IMiddleware components for logging, analytics, or transformation.

  3. Store Events: The store emits StoreEventBase events through IStore.StoreEvents, enabling external integrations (like DevTools) to observe activity via composition.

  4. Reducers Execute: The store invokes IRootReducer<TState> for each feature state. Matching reducers produce new immutable state.

  5. Listeners Notified: Subscribed listeners (via Store.Subscribe()) are notified synchronously after the action is processed.

  6. 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
  • StoreComponent and the built-in Blazor features
  • testing patterns and DevTools integration

Learn More