Need help with ngrx-store-freeze?
Click the “chat” button below for chat support from the developer who created it, or find similar developers for support.

About the developer

brandonroberts
203 Stars 13 Forks MIT License 40 Commits 7 Opened issues

Description

@ngrx/store meta reducer that prevents state from being mutated.

Services available

!
?

Need anything else?

Contributors list

# 45,851
JavaScr...
TypeScr...
ng-boot...
angular...
18 commits
# 1,919
TypeScr...
Angular
HTML
Redux
8 commits
# 599,893
TypeScr...
JavaScr...
Angular
ngrx
2 commits
# 211,743
Angular
TypeScr...
checkli...
HTML
2 commits
# 11,686
learnin...
HTML
angular...
angular...
1 commit
# 111,467
angular...
scrollt...
lodash
ESLint
1 commit
# 371,026
HTML
Shell
interac...
TypeScr...
1 commit
# 74,911
TypeScr...
Gulp
Angular
Rust
1 commit
# 665,160
TypeScr...
JavaScr...
Angular
ngrx
1 commit

ngrx-store-freeze

npm version CircleCI

ngrx-store-freeze is a meta-reducer that prevents state from being mutated

  • Recursively freezes the current state, the dispatched action payload if provided and the new state.
  • When mutation occurs, an exception will be thrown.
  • Should be used only in development to ensure that the state remains immutable.

Installation

npm i --save-dev ngrx-store-freeze

OR

yarn add ngrx-store-freeze --dev

Setup

import { StoreModule, MetaReducer, ActionReducerMap } from '@ngrx/store';
import { storeFreeze } from 'ngrx-store-freeze';
import { environment } from '../environments/environment'; // Angular CLI environment

export interface State { // reducer interfaces }

export const reducers: ActionReducerMap = { // reducers }

export const metaReducers: MetaReducer[] = !environment.production ? [storeFreeze]: [];

@NgModule({ imports: [ StoreModule.forRoot(reducers, { metaReducers }), ] }) export class AppModule {}

Additional Documentation

Credits

redux-freeze - Redux middleware that prevents state from being mutated
Attila Egyed - The original maintainer of this project

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.