I just have a basic question about order of execution in JS code.
deleteAttachement({ cdId, paId: recordId }).then(response => {
if (response) {
this.existingFilesList = this.existingFilesList.filter(file => (file.contentVersionId != cvId));
}
if(this.existingFilesList.length == 0) {
this.statusIcon = this.missingIcon;
}
}).catch(err => {
console.log(err);
});
Im trying to change the Icon based on the amount of records contained in the member variable "this.existingFilesList" (Its an array).
Im just wondering if in the code above, the second if conditional waits untill this.existingFilesList.filter() function finishes and the member variable is updated, or the filter() function just runs asynchronously in the background and as soon as it is called, the if conditional is called practically at the same time without waiting for the this.existingFilesList update.
It seems like it works and wait for it, but Im not sure if its due to the short amount of records.