我有这种情况:
- 我打开 redux-devtools。
- 单击页面上的链接。
- 该链接将我带到第二个页面,该页面启动一个 redux 效果,该效果将返回另一个动作,当“减少”时,该动作将使用页面所需的信息更改状态。
当我尝试回溯我的步骤并单击 redux-devtools 中的播放按钮时,我希望会发生这种情况:
- 该应用程序导航到第一页。
- 该应用程序导航到第二页并显示来自状态的信息。
实际发生的是:
- 该应用程序导航到第一页。
- 应用程序导航到第二个页面,然后触发效果并进入服务器并获取新数据并将其显示在页面上。
我的理解是,重放功能应该使用每个动作后的状态准确地重放事物,而不会触发任何效果。
我目前使用纯 redux 来实现 Redux。redux-observable 的效果,当然还有 angular 4+。
我调度了在组件中启动 OnInit 效果的动作。我想我错过了一些大事,正在做一些愚蠢的事情。
我在这里想念什么?
这是我创建商店的方式:
public initStore(enhancers: any[] = []) {
const rootEpic = (action$: any, store: any) => this.epics$.mergeMap(epic => epic(action$, store));
const middleware = [
createEpicMiddleware(rootEpic),
freezeMiddleware,
];
const enhancer = compose(
applyMiddleware(...middleware),
...enhancers
);
this.store = createStore<any>(this.createReducer(), enhancer);
return this.store;
}
这是 AppModule ctor:
constructor(ngRedux: NgRedux<any>, reduxRouter: ReduxRouter, devTools: DevToolsExtension) {
reduxRouter.init(state => state.router);
const enhancers = devTools.isEnabled() ? [devTools.enhancer()] : [];
ngRedux.provideStore(reduxState.initStore(enhancers));
reduxState.addReducers({
settings: settingsReducer,
global: globalErrorReducer,
session: userSessionReducer,
});
reduxState.addEpics({
explicitRouterEpic,
logEpic: (actions$: any, store: any) => actions$.do(console.log).filter((x: any) => false),
});
}