百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
N

ngrx-store-freeze

> 前端框架
开源

@ngrx/store 元减少器,可防止状态被修改。

197 stars0 点赞1 次浏览
访问官网GitHub

工具介绍

@ngrx/store 元减少器,可防止状态被修改。

ngrx-store-freeze

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

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

OR

bash
yarn add ngrx-store-freeze --dev

Setup

typescript
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

  • Usage with @ngrx/router-store

Credits

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

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

TypeScriptangularngrx

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月18日
分类前端框架
定价开源

> 相关工具

R
React
用于构建用户界面的 JavaScript 库
V
Vue.js
渐进式 JavaScript 框架
N
Next.js
基于 React 的全栈 Web 框架