0

我正在使用 Angular 和 ngrx 和 redux DevTools for Chrome 开发一个应用程序。我的应用程序还有一个延迟加载模块,我将其配置如下:

@NgModule({
    imports: [
        CommonModule,
        FormsModule,
        RouterModule.forChild([
            { path: '', component: UserLazyHistoryComponent }
        ]),
        StoreModule.forFeature(moduleFeatureName, reducers),
        EffectsModule.forFeature([
            HistoryEffects
        ])
    ],
    declarations: [UserLazyHistoryComponent]
})
export class UserLazyHistoryModule { }

这是我的减速器索引文件:

export const moduleFeatureName = 'user-lazy-module';

export interface UserLazySate {
    history: fromHistory.HistoryState;
}

export const reducers = {
    history: fromHistory.reducer
};

export const selectHistoryModuleState = createFeatureSelector<UserLazySate>(moduleFeatureName);

export const selectHistory = createSelector(selectHistoryModuleState, s => s.history);

使用此配置,一切正常,但我注意到当我使用 ReduxDevTools 导出应用程序的状态(作为 json)然后重新上传它时,惰性模块的状态没有加载。它仍然为空。

如果我在延迟加载模块的状态下启动应用程序,然后导入 json,它可以工作,但是如果我从应用程序的开头开始,然后我使用时间滑块导入 json,当我到达惰性模块,状态为空(默认)。

我做错了什么还是问题是当我进入惰性模块时它会覆盖json的状态?

非常感谢

4

0 回答 0