I'm mystified right now on what's causing this bug. I am trying to zip the result of 7 Observables like:
var zipped$ = Observable.zip(
Observable.of({prop1:1}),
Observable.of({prop2:2}),
Observable.of({prop3:3}),
Observable.of({prop4:4}),
Observable.of({prop5:5}),
Observable.of({prop6:6}),
Observable.of({prop7:7})
);
And then merge them with mergeAll() and reduce() like:
var reduced$ = zipped$.mergeAll().reduce((acc,val) => Object.assign({},acc,val));
reduced$.subscribe(final => console.log(final));
But I get this error: "property 'reduce' does not exist on type '{}'"
To add to the confusion:
If I use 6 values, it works fine.
If the observables all return primitives, it works fine.
if I add this function as the final argument in my zip:
function(...args: any[]) {
// I have no ieda why I need this hack, but the zip fails without it.
return args;
}
it works fine.
Is this a bug in RxJS? Am I missing something about the zip implementation? Is this an angular compiler thing?? No amount of searching docs has revealed a limit on the number of arguments to zip. Any insight is appreciated.
Thanks
EDIT: for any one else who finds this.
the best work around is to just stick the observables in an array and feed it as a single argument like:
var zipped$ = Observable.zip(...[
Observable.of({prop1:1}),
Observable.of({prop2:2}),
Observable.of({prop3:3}),
Observable.of({prop4:4}),
Observable.of({prop5:5}),
Observable.of({prop6:6}),
Observable.of({prop7:7})]);
which also works fine. EDIT: the array feed stopped working, now need to use spread operator and array.