0
我有一個角度服務,返回filterObservable
。RxJS - zip多個訂閱導致ts編譯器錯誤
我想通過Rx.Observable.zip()
合併多個呼叫。
它的工作原理就如同預期,但我的打字稿編譯器會引發錯誤我的方法:
error TS2346: Supplied parameters do not match any signature of call target.
,你可以給我一個提示,我在做什麼錯誤,以及如何解決這個錯誤嗎?
protected getCombinedResults(ids:number[]) {
let observablesToGetZipped = ids.map(id => this.myService.loadResource(id));
if (observablesToGetZipped.length > 1) {
return Rx.Observable
.zip(observablesToGetZipped)
.take(1);
}
return observablesToGetZipped[0].take(1);
}
我所說的方法是這樣的:
this.getCombinedResults([1,2,3,4,5]).subscribe(result => { ... });