- this.eiSvc.getProducerIds()
- .subscribe((producerIds: string[]) => {
- producerIds.forEach(id => {
- this.getJobsForProducer(id);
- });
- });
+ this.eiSvc.getProducerIds().pipe(
+ mergeMap(prodIds =>
+ forkJoin(prodIds.map(id => this.eiSvc.getJobsForProducer(id)))),
+ mergeMap(result => result),
+ finalize(() => this.loadingSubject.next(false))
+ ).subscribe(result => {
+ this.jobs = this.jobs.concat(result);
+ this.jobsSubject.next(this.jobs);
+ });