Quick Start
#
PurposeMiniRx Store provides Reactive State Management for JavaScript Applications inspired by Redux. It is a global, application-wide solution to manage state and is powered by RxJS.
#
What's Included- RxJS powered global state management
- State and actions are exposed as RxJS Observable
- Store (Redux API):
- Actions
- Reducers
- Meta Reducers
- Memoized Selectors
- Effects
- Support for ts-action: Create and consume actions with as little boilerplate as possible
- Feature Store: Update state without actions and reducers:
setState()
update the feature stateselect()
read feature stateeffect()
run side effects like API calls and update feature stateundo()
easily undo setState actions
- Extensions:
- Redux Dev Tools Extension: Inspect global state with the Redux Dev Tools
- Immutable Extension: Enforce state immutability
- Undo Extension: Undo dispatched actions
- Logger Extension: console.log the current action and updated state
- Framework agnostic: MiniRx works with any front-end project built with JavaScript or TypeScript (Angular, Svelte, React, Vue, or anything else)
- TypeScript support: The MiniRx API comes with TypeScript type definitions
- Angular Integration: Use MiniRx Store the Angular way:
StoreModule.forRoot()
,StoreModule.forFeature()
, ...
#
Key Concepts- The store is a single object which holds the global application state. It is the "single source of truth"
- State is exposed as RxJS Observable
- State has a flat hierarchy and is divided into "feature states" (also called "slices" in Redux world)
- For each "feature state" we can decide to use the Redux API with actions and a reducer or the Feature Store API with
setState
- State is read-only (immutable) and can only be changed by dispatching actions (Redux API) or by using setState (Feature Store API)
#
Basic TutorialLet's dive into some code to see MiniRx in action
#
Store (Redux API)MiniRx supports the classic Redux API with registering reducers and dispatching actions. Observable state can be selected with memoized selectors.
#
Feature Store APIFeature Stores allow us to manage feature states without actions and reducers.
The FeatureStore
API is optimized to select and update a feature state directly with a minimum of boilerplate.
Use the "counterFs" Feature Store like this:
info
The state of a Feature Store becomes part of the global state
Every new Feature Store will show up in the global state with the corresponding feature key (e.g. 'counterFs').
#
Demos- MiniRx Store - Basic Tutorial: See the basic tutorial in action
- MiniRx Store Demo: See MiniRx Feature Stores, and the MiniRx Redux API in action