From 8174947e3d4cd2212843896c99edaf8ab1e8dc62 Mon Sep 17 00:00:00 2001 From: Andre Staltz Date: Fri, 30 Oct 2015 16:03:04 +0200 Subject: [PATCH] fix(windowWhen): fix windowWhen with regard to unsubscriptions Fix windowWhen operator to unsubscribe the closingNotification observable when the source has raised an error or has completed, or received an explicit unsubscribe() call. Also change windowWhen to close a window whenever the closingNotification completes, this is aligned with how windowToggle behaves as well. --- src/operators/windowWhen.ts | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/operators/windowWhen.ts b/src/operators/windowWhen.ts index e9c1e9f213..fdd2d53f96 100644 --- a/src/operators/windowWhen.ts +++ b/src/operators/windowWhen.ts @@ -37,11 +37,25 @@ class WindowSubscriber extends Subscriber { _error(err: any) { this.window.error(err); this.destination.error(err); + this._unsubscribeClosingNotification(); } _complete() { this.window.complete(); this.destination.complete(); + this._unsubscribeClosingNotification(); + } + + unsubscribe() { + super.unsubscribe(); + this._unsubscribeClosingNotification(); + } + + _unsubscribeClosingNotification() { + let closingNotification = this.closingNotification; + if (closingNotification) { + closingNotification.unsubscribe(); + } } openWindow() { @@ -84,6 +98,6 @@ class WindowClosingNotifierSubscriber extends Subscriber { } _complete() { - // noop + this.parent.openWindow(); } } \ No newline at end of file