Observable forkJoin not firing

forkJoin emits only when all inner observables have completed.
If you need an equivalent of forkJoin that just listens to a single emission from each source, use combineLatest + take(1)

combineLatest(
  this.statuses$,
  this.companies$,
)
.pipe(
  take(1),
)
.subscribe(([statuses, companies]) => {
  console.log('forkjoin');
  this._countStatus(statuses, companies);
});

As soon as both sources emit, combineLatest will emit and take(1) will unsubscribe immediately after that.

Leave a Comment