Currently, I have a function that loops through a list of files and for each file, it triggers an async method to manipulate the image and add it to an array.
The problem is that the async calls are occurring simultaneously, causing the UI to freeze. My goal is to iterate through the list sequentially, waiting for each task to finish before moving on to the next one.
Array.from(files).forEach(data => {
if (data.size > 5000000) {
this.toastr_service.error('FILE ' + data.name + ' EXCEEDS FILE SIZE LIMIT (5MB)');
}else {
this.asyncFunc(data).subscribe(result => {
this._photos.push(result);
}, error => {
console.log(error);
});
}
});