ku-ngrx-store-freeze
TypeScript icon, indicating that this package has built-in type declarations

0.1.12 • Public • Published

ngrx-store-freeze

NPM

@ngrx/store meta reducer that prevents state from being mutated. When mutation occurs, an exception will be thrown. This is useful during development mode to ensure that no part of the app accidentally mutates the state. Ported from redux-freeze

Usage

You should only include this meta reducer (middleware) in development environment.

npm i --save-dev ngrx-store-freeze
import { bootstrap } from '@angular/platform-browser-dynamic';
import { compose } from '@ngrx/core/compose';
import { combineReducers, provideStore } from '@ngrx/store';
import { storeFreeze } from 'ngrx-store-freeze';
import { TodoApp } from './todo-app.component';
import { todoReducer, visibilityFilterReducer } from './reducers'

const metaReducers = __IS_DEV__
  ? [storeFreeze, combineReducers]
  : [combineReducers];

const store = compose(...metaReducers)({
  todos: todoReducer,
  visibilityFilter: visibilityFilterReducer
});

bootstrap(TodoApp, [
  provideStore(store)
]);

Package Sidebar

Install

npm i ku-ngrx-store-freeze

Weekly Downloads

2

Version

0.1.12

License

MIT

Last publish

Collaborators

  • rkusuma