Skip to content

Commit

Permalink
fix(windowWhen): don't signal on complete
Browse files Browse the repository at this point in the history
  • Loading branch information
jakovljevic-mladen committed Sep 1, 2022
1 parent 1226112 commit 26ad3c4
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 21 deletions.
38 changes: 18 additions & 20 deletions spec/operators/windowWhen-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,21 @@ describe('windowWhen', () => {

it('should emit windows that close and reopen', () => {
rxTestScheduler.run(({ hot, cold, expectObservable, expectSubscriptions }) => {
const e2 = cold(' -----------| ');
// -----------|
// -----------|
const e2 = cold(' -----------x| ');
// -----------x|
// -----------x|
const e2subs = [
' ^----------! ',
' -----------^----------! ',
' ----------------------^----!',
' ^----------! ',
' -----------^----------! ',
' ----------------------^----!',
];
const e1 = hot(' --a--^--b--c--d--e--f--g--h--i--|');
const e1subs = ' ^--------------------------!';
const expected = ' a----------b----------c----|';
const e1 = hot('--a--^--b--c--d--e--f--g--h--i--|');
const e1subs = ' ^--------------------------!';
const expected = ' a----------b----------c----|';

const a = cold(' ---b--c--d-| ');
const b = cold(' -e--f--g--h| ');
const c = cold(' --i--|');
const a = cold(' ---b--c--d-| ');
const b = cold(' -e--f--g--h| ');
const c = cold(' --i--|');
const values = { a: a, b: b, c: c };

const source = e1.pipe(windowWhen(() => e2));
Expand Down Expand Up @@ -102,7 +102,7 @@ describe('windowWhen', () => {
});
});

it('should emit windows using varying empty delayed closings', () => {
it('should not emit windows using varying empty delayed closings', () => {
rxTestScheduler.run(({ hot, cold, expectObservable, expectSubscriptions }) => {
const closings = [
cold(' -----------------| '),
Expand All @@ -111,17 +111,15 @@ describe('windowWhen', () => {
];
const closeSubs = [
' ^----------------! ',
' -----------------^----! ',
' ----------------------^------------! ',
' ',
' ',
];
const e1 = hot('--a--^---b---c---d---e---f---g---h------| ');
const e1subs = ' ^----------------------------------! ';
const expected = ' x----------------y----z------------| ';
const expected = ' x----------------------------------| ';

const x = cold(' ----b---c---d---e| ');
const y = cold(' ---f-| ');
const z = cold(' --g---h------| ');
const values = { x: x, y: y, z: z };
const x = cold(' ----b---c---d---e---f---g---h------| ');
const values = { x: x };

let i = 0;
const result = e1.pipe(windowWhen(() => closings[i++]));
Expand Down
3 changes: 2 additions & 1 deletion src/internal/operators/windowWhen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { ObservableInput, OperatorFunction } from '../types';
import { operate } from '../util/lift';
import { createOperatorSubscriber } from './OperatorSubscriber';
import { innerFrom } from '../observable/innerFrom';
import { noop } from '../util/noop';

/**
* Branch out the source Observable values as a nested Observable using a
Expand Down Expand Up @@ -95,7 +96,7 @@ export function windowWhen<T>(closingSelector: () => ObservableInput<any>): Oper
// to capture the subscriber (aka Subscription)
// so we can clean it up when we close the window
// and open a new one.
closingNotifier.subscribe((closingSubscriber = createOperatorSubscriber(subscriber, openWindow, openWindow, handleError)));
closingNotifier.subscribe((closingSubscriber = createOperatorSubscriber(subscriber, openWindow, noop, handleError)));
};

// Start the first window.
Expand Down

0 comments on commit 26ad3c4

Please sign in to comment.