From 712feceb78ed018c30f71012ec3a6a7f1a0f4162 Mon Sep 17 00:00:00 2001 From: Martin Sikora Date: Thu, 9 Mar 2017 22:09:02 +0100 Subject: [PATCH] fix(zipAll): complete when the source is empty #2426 --- spec/operators/zipAll-spec.ts | 7 +++++++ src/operator/zip.ts | 6 ++++++ 2 files changed, 13 insertions(+) diff --git a/spec/operators/zipAll-spec.ts b/spec/operators/zipAll-spec.ts index d122416160..58e52e28f1 100644 --- a/spec/operators/zipAll-spec.ts +++ b/spec/operators/zipAll-spec.ts @@ -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); + }); }); diff --git a/src/operator/zip.ts b/src/operator/zip.ts index f729db4442..7358488966 100644 --- a/src/operator/zip.ts +++ b/src/operator/zip.ts @@ -145,6 +145,12 @@ export class ZipSubscriber extends Subscriber { 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 = iterators[i];