From a06f3053e98a326057f0f6fe0a0e73f2d971b0d7 Mon Sep 17 00:00:00 2001 From: Nicholas Jamieson Date: Tue, 27 Oct 2020 11:17:39 +1000 Subject: [PATCH] fix(windowToggle): don't signal on complete BREAKING CHANGE: the observable returned by the windowToggle operator's closing selector must emit a next notification to close the window. Complete notifications no longer close the window. Closes #5838 --- spec/operators/windowToggle-spec.ts | 20 ++++++++++---------- src/internal/operators/windowToggle.ts | 4 ++-- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/spec/operators/windowToggle-spec.ts b/spec/operators/windowToggle-spec.ts index 4e0e3128ba0..95e05ef63d4 100644 --- a/spec/operators/windowToggle-spec.ts +++ b/spec/operators/windowToggle-spec.ts @@ -13,9 +13,9 @@ describe('windowToggle', () => { const subs = '^ !'; const e2 = cold( '----w--------w--------w--|'); const e2subs = '^ !'; - const e3 = cold( '-----| '); - // -----(c|) - // -----(c|) + const e3 = cold( '-----x '); + // -----x + // -----x const e3subs = [ ' ^ ! ', // eslint-disable-line array-bracket-spacing ' ^ ! ', ' ^ !']; @@ -121,17 +121,17 @@ describe('windowToggle', () => { expectSubscriptions(closings[2].obs.subscriptions).toBe(closings[2].sub); }); - it('should emit windows using constying empty delayed closings', () => { + it('should emit windows using varying empty delayed closings', () => { const e1 = hot('--a--^---b---c---d---e---f---g---h------| '); const e1subs = '^ ! '; const e2 = cold('--x-----------y--------z---| '); const e2subs = '^ ! '; const close = [cold( '---------------| '), - cold( '----| '), - cold( '---------------|')]; + cold( '----| '), + cold( '---------------|')]; const expected = '--x-----------y--------z-----------| '; - const x = cold( '--b---c---d---e| '); - const y = cold( '--e-| '); + const x = cold( '--b---c---d---e---f---g---h------| '); + const y = cold( '--e---f---g---h------| '); const z = cold( '-g---h------| '); const values = { x, y, z }; @@ -419,8 +419,8 @@ describe('windowToggle', () => { const e2subs = '^ ! '; const e3 = EMPTY; const expected = '---x---------------y---------------|'; - const x = cold( '|'); - const y = cold( '|'); + const x = cold( '-b---c---d---e---f---g---h------|'); + const y = cold( '-f---g---h------|'); const values = { x, y }; const result = e1.pipe(windowToggle(e2, () => e3)); diff --git a/src/internal/operators/windowToggle.ts b/src/internal/operators/windowToggle.ts index eb146b04949..ba2b57b88ee 100644 --- a/src/internal/operators/windowToggle.ts +++ b/src/internal/operators/windowToggle.ts @@ -50,7 +50,7 @@ import { arrRemove } from '../util/arrRemove'; * windows. * @param {function(value: O): Observable} closingSelector A function that takes * the value emitted by the `openings` observable and returns an Observable, - * which, when it emits (either `next` or `complete`), signals that the + * which, when it emits a next notification, signals that the * associated window should complete. * @return {Observable>} An observable of windows, which in turn * are Observables. @@ -92,7 +92,7 @@ export function windowToggle( subscriber.next(window.asObservable()); - closingSubscription.add(closingNotifier.subscribe(new OperatorSubscriber(subscriber, closeWindow, handleError, closeWindow))); + closingSubscription.add(closingNotifier.subscribe(new OperatorSubscriber(subscriber, closeWindow, handleError, noop))); }, undefined, noop