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
201 Stars 14 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

# 43,267
JavaScr...
TypeScr...
seed
ng-boot...
18 commits
# 1,751
TypeScr...
Angular
HTML
Redux
8 commits
# 596,543
TypeScr...
JavaScr...
Angular
ngrx
2 commits
# 210,222
Angular
checkli...
CSS
HTML
2 commits
# 26,891
learnin...
HTML
angular...
angular...
1 commit
# 106,584
seed
angular...
scrollt...
lodash
1 commit
# 361,312
HTML
Shell
interac...
TypeScr...
1 commit
# 72,256
TypeScr...
Gulp
Angular
Rust
1 commit
# 664,369
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.