Skip to content

Commit

Permalink
fix(windowToggle): don't signal on complete
Browse files Browse the repository at this point in the history
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 ReactiveX#5838
  • Loading branch information
cartant committed Oct 31, 2020
1 parent aed40a0 commit a06f305
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
20 changes: 10 additions & 10 deletions spec/operators/windowToggle-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
' ^ ! ',
' ^ !'];
Expand Down Expand Up @@ -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 };

Expand Down Expand Up @@ -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));
Expand Down
4 changes: 2 additions & 2 deletions src/internal/operators/windowToggle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<Observable<T>>} An observable of windows, which in turn
* are Observables.
Expand Down Expand Up @@ -92,7 +92,7 @@ export function windowToggle<T, O>(

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
Expand Down

0 comments on commit a06f305

Please sign in to comment.