Skip to content

Commit 8174947

Browse files
staltzkwonoj
authored andcommitted
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.
1 parent a95ed6b commit 8174947

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

src/operators/windowWhen.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,25 @@ class WindowSubscriber<T> extends Subscriber<T> {
3737
_error(err: any) {
3838
this.window.error(err);
3939
this.destination.error(err);
40+
this._unsubscribeClosingNotification();
4041
}
4142

4243
_complete() {
4344
this.window.complete();
4445
this.destination.complete();
46+
this._unsubscribeClosingNotification();
47+
}
48+
49+
unsubscribe() {
50+
super.unsubscribe();
51+
this._unsubscribeClosingNotification();
52+
}
53+
54+
_unsubscribeClosingNotification() {
55+
let closingNotification = this.closingNotification;
56+
if (closingNotification) {
57+
closingNotification.unsubscribe();
58+
}
4559
}
4660

4761
openWindow() {
@@ -84,6 +98,6 @@ class WindowClosingNotifierSubscriber<T> extends Subscriber<T> {
8498
}
8599

86100
_complete() {
87-
// noop
101+
this.parent.openWindow();
88102
}
89103
}

0 commit comments

Comments
 (0)