diff --git a/src/operator/retry.ts b/src/operator/retry.ts index 4515bd5079..4fed734503 100644 --- a/src/operator/retry.ts +++ b/src/operator/retry.ts @@ -23,7 +23,8 @@ class FirstRetrySubscriber extends Subscriber { constructor(public destination: Subscriber, private count: number, private source: Observable) { - super(null); + super(); + destination.add(this); this.lastSubscription = this; } @@ -33,29 +34,23 @@ class FirstRetrySubscriber extends Subscriber { error(error?) { if (!this.isUnsubscribed) { - super.unsubscribe(); + this.unsubscribe(); this.resubscribe(); } } _complete() { - super.unsubscribe(); + this.unsubscribe(); this.destination.complete(); } - unsubscribe() { - const lastSubscription = this.lastSubscription; - if (lastSubscription === this) { - super.unsubscribe(); - } else { - lastSubscription.unsubscribe(); - } - } - resubscribe(retried: number = 0) { - this.lastSubscription.unsubscribe(); + const { lastSubscription, destination } = this; + destination.remove(lastSubscription); + lastSubscription.unsubscribe(); const nextSubscriber = new RetryMoreSubscriber(this, this.count, retried + 1); this.lastSubscription = this.source.subscribe(nextSubscriber); + destination.add(this.lastSubscription); } }