RxJs – forkJoin with empty array

That’s because forkJoin requires all source Observables to emit at least one item and when there are no source Observables there’s nothing to emit. However, forkJoin will still send the complete notification so you can use for example defaultIfEmpty operator to make sure it always emits at least one next.

forkJoin(observables).pipe(
  defaultIfEmpty(null),
).subscribe(...);

Demo: https://stackblitz.com/edit/rxjs-kkd1qa?file=index.ts

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)