gpt4 book ai didi

angular - storeFreeze 和 ngrx8

转载 作者:行者123 更新时间:2023-12-05 08:40:10 41 4
gpt4 key购买 nike

我刚刚升级到 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') ? [] : [];

最佳答案

如果您运行 ng update @ngrx/store,这是迁移的一部分。它还应该添加 runtime checks作为替代品,因为它现在是 ngrx 的一部分:

@NgModule({
imports: [
StoreModule.forRoot(reducers, {
runtimeChecks: {
strictStateImmutability: true,
strictActionImmutability: true,
},
}),
],
})
export class AppModule {}

关于angular - storeFreeze 和 ngrx8,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57004187/

41 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com