Property 'replaceReducer' does not exist on type 'Store<State>' After upgrading @ngrx/store

大憨熊 提交于 2019-12-13 03:23:53

问题


In my Angular app, I have a function which replaces replaces the current reducer used by the Store. However, after upgrade from @ngrx/store v2.2.2 to v6.1.0, "replaceReducer" function seems to have been removed from the Store interface.

I've gone through the NGRX migration guide (https://github.com/ngrx/platform/blob/master/MIGRATION.md) hoping to find a possible solution or an alternative way to go around the issue but I can't find any reference to the removed "replaceReducer" function interface.

Here is my code:

export const accountingModuleReducer: ActionReducer<State> = createReducer(reducers);

export function accountingStoreFactory(appStore: Store<fromRoot.State>) {
  appStore.replaceReducer(accountingModuleReducer);
  return appStore;
}

回答1:


Replace Reducer has been deprecated. Checkout this issue to see an alternative way to approach this problem. Also checkout the StoreModule.forFeature() docs here, which might help you out.



来源:https://stackoverflow.com/questions/52741023/property-replacereducer-does-not-exist-on-type-storestate-after-upgrading

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!