-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
passing empty array into combineLatest closes subscription prematurely #7110
Labels
AGENDA ITEM
Flagged for discussion at core team meetings
Comments
mkhodan
changed the title
passing empty array into combineLatest immediately closes subscription prematurely
passing empty array into combineLatest closes subscription prematurely
Nov 4, 2022
jakovljevic-mladen
added
the
AGENDA ITEM
Flagged for discussion at core team meetings
label
Jul 24, 2023
This looks like it's happening because we're examining the array given prior to subscription, we're not assuming that someone might mutate the array after that. The workaround for now would be to create the array prior to passing it to the import { combineLatest, of, defer } from "rxjs";
let observables = [];
let result = defer(() => combineLatest(observables))
for (let i = 0; i < 20; i++) {
observables.push(of(i));
}
result.subscribe((numbers) => console.log(numbers)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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
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
The text was updated successfully, but these errors were encountered: