storeFreeze 和 ngrx8
storeFreeze and ngrx8
我刚刚升级到 ngrx/store 版本 8。我注意到 ng 更新已经删除了所有出现的 storeFreeze。也将其从 metaReducer 中删除。
所以我的问题是 - 为什么?
在 ngrx 8 上使用 storeFreeze 有问题吗?
ngrx8 之前:
import { ActionReducerMap, MetaReducer } from '@ngrx/store';
import { storeFreeze } from 'ngrx-store-freeze';
import * as fromGroupMember from './group-member.reducer';
import * as fromDirectoryForm from './directory-filter-form.reducer';
export const metaReducers: MetaReducer<IState>[] =
(localStorage && localStorage.getItem('production') === 'false') ? [storeFreeze] : [];
之后:
import { ActionReducerMap, MetaReducer } from '@ngrx/store';
import * as fromGroupMember from './group-member.reducer';
import * as fromDirectoryForm from './directory-filter-form.reducer';
export const metaReducers: MetaReducer<IState>[] =
(localStorage && localStorage.getItem('production') === 'false') ? [] : [];
已在 8.0.0-rc.1 上添加迁移以删除 ngrx-store-freeze
的用法,根据:
The majority of our users are probably using ngrx-store-freeze to
guard against state mutations. We have built-in run-time checks in
version 8 to guard against those.
参见github issue。
如果您 运行 ng update @ngrx/store
,这是迁移的一部分。
它还应该添加 runtime checks 作为替代,因为它现在是 ngrx 的一部分:
@NgModule({
imports: [
StoreModule.forRoot(reducers, {
runtimeChecks: {
strictStateImmutability: true,
strictActionImmutability: true,
},
}),
],
})
export class AppModule {}
我刚刚升级到 ngrx/store 版本 8。我注意到 ng 更新已经删除了所有出现的 storeFreeze。也将其从 metaReducer 中删除。
所以我的问题是 - 为什么?
在 ngrx 8 上使用 storeFreeze 有问题吗?
ngrx8 之前:
import { ActionReducerMap, MetaReducer } from '@ngrx/store';
import { storeFreeze } from 'ngrx-store-freeze';
import * as fromGroupMember from './group-member.reducer';
import * as fromDirectoryForm from './directory-filter-form.reducer';
export const metaReducers: MetaReducer<IState>[] =
(localStorage && localStorage.getItem('production') === 'false') ? [storeFreeze] : [];
之后:
import { ActionReducerMap, MetaReducer } from '@ngrx/store';
import * as fromGroupMember from './group-member.reducer';
import * as fromDirectoryForm from './directory-filter-form.reducer';
export const metaReducers: MetaReducer<IState>[] =
(localStorage && localStorage.getItem('production') === 'false') ? [] : [];
已在 8.0.0-rc.1 上添加迁移以删除 ngrx-store-freeze
的用法,根据:
The majority of our users are probably using ngrx-store-freeze to guard against state mutations. We have built-in run-time checks in version 8 to guard against those.
参见github issue。
如果您 运行 ng update @ngrx/store
,这是迁移的一部分。
它还应该添加 runtime checks 作为替代,因为它现在是 ngrx 的一部分:
@NgModule({
imports: [
StoreModule.forRoot(reducers, {
runtimeChecks: {
strictStateImmutability: true,
strictActionImmutability: true,
},
}),
],
})
export class AppModule {}