1๐
โ
So from what you tell us, I assume that focus, map, and selected are data objects that might get changed. The following code would execute the function in handler once there is a change:
watch: {
focus: {
handler: function() {
this.visible = this.focus.map(bool => bool)
}, deep: true
},
map: function(newval, oldval) {
Vue.set(this.nmap, oldval, !this.nmap[oldval])
Vue.set(this.nmap, newval, !this.nmap[newval])
},
selected: {
handler: function(newval, oldval) {
console.log('Old val:')
console.log(oldval)
console.log('New val:')
console.log(newval)
}, deep: true,
}
}
Source: VueJS Docs
Source:stackexchange.com