I want to check if an object has new subobjects. I mean I have an object with x nested objects, but I will check it if the main object has new objects. Is there any existing solution to check this out?
methods: {
playSound(newOrders, sound) {
if (newOrders.length > 0) {
if (sound) {
var audio = new Audio(sound);
audio.play();
}
}
}
},
beforeUpdate() {
this.playSound(this.newOrders, 'http://soundbible.com/mp3/Elevator Ding-SoundBible.com-685385892.mp3')
},
My goal is to call the function playSound
if the newOrders
object has new items. This code calls the function every time when the array changes.
Also when some items are removed. This part of the functionality is wrong. Any idea to fix it?