Skip to content

Commit

Permalink
fix(windowWhen): fix windowWhen with regard to unsubscriptions
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
staltz authored and kwonoj committed Nov 5, 2015
1 parent a95ed6b commit 8174947
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/operators/windowWhen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,25 @@ class WindowSubscriber<T> extends Subscriber<T> {
_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() {
Expand Down Expand Up @@ -84,6 +98,6 @@ class WindowClosingNotifierSubscriber<T> extends Subscriber<T> {
}

_complete() {
// noop
this.parent.openWindow();
}
}

0 comments on commit 8174947

Please sign in to comment.