我们的 ngrx Angular 应用程序运行良好,直到我们卸载 Redux Devtools 时出现错误:
您在预期流的位置提供了无效对象。您可以提供 Observable、Promise、Array 或 Iterable。
商店设置在 app.module.ts 中如下所示:
StoreModule.forRoot(reducers, {metaReducers}),
!environment.production ? StoreDevtoolsModule.instrument() : [],
EffectsModule.forRoot([SimsEffects, FiltersEffects, OmnipresentEffects, UserEffects, InitEffects]),
StoreRouterConnectingModule.forRoot({stateKey: 'router'})
我们的ngrx reducers/index.ts 文件看起来像这样:
export interface AppState {
router: any,
omnipresent: OmnipresentState,
user: UserState
}
export const reducers: ActionReducerMap<AppState> = {
router: routerReducer,
omnipresent: omnipresentReducer,
user: userReducer
}
export function resetStore(reducer) {
return (state, action) => {
return reducer(action.type === InitActionTypes.ResetStore ? undefined : state, action)
}
}
// storeFreeze throws an error early if state is mutated, avoiding hard to debug state mutation issues
export const metaReducers: MetaReducer<AppState>[] = !environment.production ? [resetStore, storeFreeze] : [resetStore] // tslint:disable-line array-type
有没有人经历过这种情况或知道修复方法?该问题存在于开发和生产环境中。
我们正在运行 Node v8.11.3
编辑:如果我注释掉这一行,错误就会消失,但显然商店无法初始化:
@Effect()
init$: Observable<any> = defer(() => {
return of(new InitAction())
})
其中 InitAction 只是一个不执行任何操作且不附加任何效果的操作(为了帮助调试它)。