Skip to content

passing empty array into combineLatest closes subscription prematurely #7110

Open
@mkhodan

Description

@mkhodan

Describe the bug

Since rxjs 7 passing empty array into combineLatest and filling it later doesn't work as it immediately closes subscription even though we haven't subscribed yet.

Expected behavior

combineLatest waits until subscription and only then decides whether array is actually empty.

Reproduction code

e.g. this code worked in 6.6.2 but doesn't work anymore in 7.5.7

import { combineLatest, of } from 'rxjs';

let observables = [];

let result = combineLatest(observables);

for (let i = 0; i < 20; i++) {
  observables.push(of(i));
}

result.subscribe((numbers) => console.log(numbers));

please note that if we create array with at least 1 observable already there this works as expected in rxjs 7:
let observables = [of(-1)];

Reproduction URL

https://stackblitz.com/edit/rxjs-6-daddo-playground-is6lgj?file=index.ts
https://stackblitz.com/edit/rxjs-7-playground-3urg4j?file=index.ts

Version

7.5.7

Environment

No response

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    AGENDA ITEMFlagged for discussion at core team meetings

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions