Skip to content

Commit

Permalink
fix(zipAll): complete when the source is empty
Browse files Browse the repository at this point in the history
  • Loading branch information
martinsik committed Mar 9, 2017
1 parent 69d051b commit 712fece
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
7 changes: 7 additions & 0 deletions spec/operators/zipAll-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -723,4 +723,11 @@ describe('Observable.prototype.zipAll', () => {
expectSubscriptions(a.subscriptions).toBe(asubs);
expectSubscriptions(b.subscriptions).toBe(bsubs);
});

it('should complete when empty source', () => {
const source = hot('|');
const expected = '|';

expectObservable(source.zipAll()).toBe(expected);
});
});
6 changes: 6 additions & 0 deletions src/operator/zip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,12 @@ export class ZipSubscriber<T, R> extends Subscriber<T> {
protected _complete() {
const iterators = this.iterators;
const len = iterators.length;

if (len === 0) {
this.destination.complete();
return;
}

this.active = len;
for (let i = 0; i < len; i++) {
let iterator: ZipBufferIterator<any, any> = <any>iterators[i];
Expand Down

0 comments on commit 712fece

Please sign in to comment.