I\'m currently struggling with multiples/forEach subscribe inside a subscribe, I\'m trying to retreive a list of objects then retreive their images thanks to their ID. Curre
Since you already understood the usage of forkJoin, you are sort of on the right direction.
RxJS's forkJoin()
will for the Array.forEach()
loop to be completed before returning all the observables. If you are familiar with the usage of Promises in JavaScript, it is actually similar to Promise.all
.
const observablesList = [];
apps.forEach(app => {
observablesList.push(this.appTypeService.getPhoto(app.Id));
})
forkJoin(observablesList).subscribe(response => {
console.log(response);
// handle the rest
});