【发布时间】:2019-04-14 16:45:29
【问题描述】:
我想在两个 Observables 返回值后调用一个方法。我做了一些搜索,似乎forkJoin 是我想要的,但我无法让它工作。我知道这两个 Observable 都在返回值,因为我在组件的其他地方单独使用每个数据,所以很明显我做错了。
这是我尝试过的。我正在使用 rxjs v6.4。
forkJoin(
this.store.pipe(select(fromStore.getAppointmentsLoading)),
this.clientStore.pipe(select(fromClientStore.getClientsLoading)),
).subscribe(
([res1, res2]) => {
console.log('res1', res1);
console.log('res2', res2);
},
err => console.error(err),
);
没有任何东西记录到控制台,我也没有收到任何错误。同样,我传入的 Observable 肯定是返回值。
我是在做错什么,还是我完全使用 forkJoin 采取了错误的方法?
【问题讨论】:
-
forkJoin一直等到所有源完成,这种情况会发生吗?也许尝试combineLatest或zip看看它们是否在未完成的情况下发出。
标签: angular rxjs ngrx fork-join