Reputation: 21
I need to put an array of observables to Observable.zip, but I don't know how to create a function for read values. Array is dynamically sized. Any ideas?
import {Observable} from "rxjs/Observable";
import "rxjs/add/observable/zip";
obsArray;
functionName():Observable<any>{
return Observable.zip(...obsArray, (arg1, arg2, arg3, ...) => {
return { arg1: arg1, arg2: arg2, arg3: arg3, ...}
})
}
Upvotes: 2
Views: 1067
Reputation: 2039
spread the array into the zip function and receive the response object.
You can run a res.length
to get the length and use a for loop or run the foreach loop on it
import {Observable} from "rxjs/Observable";
import "rxjs/add/observable/zip";
obsArray;
functionName():Observable<any>{
return Observable.zip(...obsArray)
}
Upvotes: 1