I'm watching a computed property returning a state variable.
I know for sure that this state variable changes as a result of certain things I do. Yet the console.log()
code in my watch: {}
never executes:
computed: {
simulation () {
return this.$store.state.simulation
}
},
watch: {
simulation () {
console.log('simulation changed:')
}
}
What am I doing wrong?
If your this.$store.state.simulation
is object, you can't watch for change property of object. You can watch change of object (when this.$store.state.simulation = newVal
, but not this.$store.state.simulation.anyProp = newVal
)
you should use deep watch (https://v2.vuejs.org/v2/api/#watch)