From 3b8cf948246158966ab8b8ec2a94d49a7acac45e Mon Sep 17 00:00:00 2001 From: OJ Kwon Date: Wed, 25 Nov 2015 11:19:47 -0800 Subject: [PATCH] fix(expand): terminate recursive call when destination completes relates to #766 --- src/operators/expand-support.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/operators/expand-support.ts b/src/operators/expand-support.ts index 7b16b1969b..187f4f624f 100644 --- a/src/operators/expand-support.ts +++ b/src/operators/expand-support.ts @@ -33,12 +33,19 @@ export class ExpandSubscriber extends OuterSubscriber { } _next(value: any): void { + const destination = this.destination; + + if (destination.isUnsubscribed) { + this._complete(); + return; + } + const index = this.index++; if (this.active < this.concurrent) { - this.destination.next(value); + destination.next(value); let result = tryCatch(this.project)(value, index); if (result === errorObject) { - this.destination.error(result.e); + destination.error(result.e); } else { if (result._isScalar) { this._next(result.value);