我不明白为什么我能做到
ForkJoin(service.Obs1(), service.Obs2()).subscribe
但是,如果我重构我的代码,以便向我的服务类添加一个返回的方法ForkJoin(this.Obs1(), this.Obs2()),例如
updateWhatever(): Observable<[string, string]> {
return forkJoin([
this.Obs1(),
this.Obs(2)
]);}
然后如果我这样做service.updateWhatever().subscribe(res => //handle res[].,它会抛出错误
You provided an invalid object where a stream was expected. You can provide an Observable, Promise, Array, or Iterable
为什么这行不通?人们应该能够以这种方式进行重构。我错过了什么?我意识到它返回了一个可观察的数组,但是为什么函数调用不处理这个呢?
也许我的问题是,如何处理返回 forkJoin 的方法?