I'm using Angular 9. I have the following component that displays a number of images
<mat-grid-tile *ngFor="let person of pageData; let i = index;" class="animated flipInX">
...
<img [src]="images[i]"
alt="" width="100%">
The images are loaded below using forkJoin. This accomplishes the goal of being able to load my images in parallel ...
let images$ = [];
res.forEach(( componentarray, key ) => {
images$.push(
this.authService.getImage(res[key].Id)
);
});
const getImagesObservable = forkJoin(images$);
getImagesObservable.subscribe(results => {
results.forEach(( result, idx ) => {
this.createTheImage(result, idx);
})
});
});
The issue that I'm wondering about is that the images are only displayed when they are all loaded (all the calls complete). I was curious if there is a way to load the images in parallel but also display the images as each call completes.