Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 25 additions & 1 deletion packages/rxjs/spec/observables/zip-spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/** @prettier */
import { expect } from 'chai';
import { queueScheduler as rxQueueScheduler, zip, from, scheduled } from 'rxjs';
import { queueScheduler as rxQueueScheduler, zip, from, scheduled, of, config, concat, NEVER, first, delay, filter, GlobalConfig } from 'rxjs';
import { TestScheduler } from 'rxjs/testing';
import { observableMatcher } from '../helpers/observableMatcher';

Expand Down Expand Up @@ -630,4 +630,28 @@ describe('zip', () => {

expect(results).to.deep.equal(['done']);
});

describe('with a registered notificaiton handler', () => {
let onStoppedNotification: GlobalConfig['onStoppedNotification'];

beforeEach(() => onStoppedNotification = config.onStoppedNotification);

afterEach(() => config.onStoppedNotification = onStoppedNotification);

it('should handle when unsubscribing from within a next handler', (done) => {
let error: any = null;

config.onStoppedNotification = (notification) => {
if (notification.kind === 'E') {
error = notification.error;

done(notification.error);
}
};

const source$ = concat(of(1), NEVER);

zip(source$).pipe(first(), delay(1), filter(() => error === null)).subscribe(() => done());
});
});
});
2 changes: 1 addition & 1 deletion packages/rxjs/src/internal/observable/zip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ export function zip(...args: unknown[]): Observable<unknown> {
// If any one of the sources is both complete and has an empty buffer
// then we complete the result. This is because we cannot possibly have
// any more values to zip together.
if (buffers.some((buffer, i) => !buffer.length && completed[i])) {
if (buffers?.some((buffer, i) => !buffer.length && completed[i])) {
destination.complete();
}
}
Expand Down
Loading