【发布时间】:2019-06-05 08:14:44
【问题描述】:
我有两个需要循环的集合,我首先获取用户组,然后遍历每个组并获取与该组关联的作业。这可以完美运行,但问题是如果没有作业,应用程序将保持加载状态。
这是我的代码:
this.fb
.getUsersGroupsAsObservable(user.uid, groupType) // first get the users groups
.subscribe(groups => {
combineLatest( // for each group get the jobs belonging to that group
groups.map(group => this.fb.getJobsbyGroup(group.id)),
).subscribe(res => { // if there is no results this wont execute
this.jobs = [].concat.apply([], res);
});
});
理想情况下,如果我能确定 getJobsbyGroup 没有返回任何结果并返回一个空数组,那就太好了。抱歉,如果措辞不好,我对这种情况所需的术语并不完全有信心。
【问题讨论】:
标签: rxjs google-cloud-firestore angularfire2