2016-09-21 59 views
0

我有一个角度服务,返回filterObservableRxJS - 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 => { ... }); 

回答

0

对于任何人谁是感兴趣的解决方案:

这并获得成功,我

return Rx.Observable 
    .zip.apply(Rx.Observable, observablesToGetZipped)