问题描述
// in providers section of file: 'app.module'
{
provide: APP_INITIALIZER,useFactory: (store: Store<AppState>) => {
return async () => {
store.dispatch(fetchUser());
};
},multi: true,deps: [Store],},
我想等待fetchUser()操作完成(并触发它为“成功”或“失败”操作...
我在同一段代码中尝试过类似的操作:
store.pipe(select('user'))
.subscribe((userState) => {
debugger;
store.dispatch(fetchTeam(user.team.id));
});
fetchTeam()
的作用破坏了应用程序的ngrx部分,调试器崩溃。我还尝试过滤流,然后在tap
中调用效果,这不会使商店崩溃,但不会触发效果。
我需要使用商店的user
部分中的数据来获取team
,所以我需要等待user
效果返回一些数据后才能使用fetchTeam
效果...谢谢您的帮助!
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)