【发布时间】:2018-10-17 07:07:43
【问题描述】:
我在一个数组中有多个商店订阅,我想仅在所有可观察对象都返回结果时使用 forkJoin 来获取结果。 类似的东西:
this.subscriptionsArray = this.store.select('state')
forkJoin(this.subscriptionsArray).subscribe(sub => {
// do something here with response
});
问题是商店没有发出任何东西。
我在 GitHub 存储库上找到了解决方案:
this.subscriptionsArray = this.store.select('state').pipe(first())
这项工作,但我需要最后发出的结果,而明显的解决方案不起作用。以下代码不起作用:
this.subscriptionsArray = this.store.select('state').pipe(last())
【问题讨论】:
-
combineLatest怎么样?它在所有可观察对象 emit 时发出。forkJoin在所有可观察对象完成时发出。
标签: angular observable ngrx