Hello i have a function that recieves a percentage of download of a file, and i use vue set to add the property to the object cuz it's not reactive yet, now this function gets called every second to update the percentage and i'm wondering if it's ok to always use vue set to both set it and update the value, or after i used vue set check if the property it's there and then update it regularly
So i can always call this like this
SettaPerc(fileIndex = -1, profIndex = -1,perc = 0) {
if (profIndex === -1) {
this.$set(this.file[fileIndex], "perc", perc);
} else {
this.$set(this.file[profIndex].linkondi[fileIndex], "perc", perc);
}
},
Or it's better to do this
SettaPerc(fileIndex = -1, profIndex = -1, perc = 0) {
if (profIndex === -1) {
if (this.file[fileIndex].perc === undefined) {
this.$set(this.file[fileIndex], "perc", perc);
} else {
this.file[fileIndex].perc = perc
}
} else {
if (this.file[profIndex].linkondi[fileIndex] === undefined) {
this.$set(this.file[profIndex].linkondi[fileIndex], "perc", perc);
} else {
this.file[profIndex].linkondi[fileIndex] = perc
}
}
},