0π
I post the same question on forum.vuejs.org, and get answer there, so I add the link to that answer here for anyone who may have the same question.
http://forum.vuejs.org/topic/4605/use-watch-in-store-pattern/3
0π
I have an ugly solution for my problem: add a computed property to listen to the exact property in that shared object.
computed: {
compIndex: function () {
console.log(`caught in computed value`)
doSomething()
return this.index.data
}
},
This computed property must be stored in a hidden element so that the doSomething can be called.
Any better ideas?
0π
The answer @ericchan1336 got on Vue forums copied here for reference:
the watch function is never fired because the index property itself never changes β it always contains the same object, only properties inside that object change.
For these cases, thereβs the deep: true option, which makes the watch inspect deep changes nested inside the watched property:
watch: {
'index': {
deep: true,
handler: function (val) {
doSmething()
}
}
}