Reputation: 4182
I need to watch Vuex store. The problem is that the store is dynamic store. As I know I can watch Vuex store as string but how to do it with dynamic store which name is in the variable?
I found this code:
watch: {
'$store.state.local_store.list_of_data':{
handler(){
console.log("value changeing in party sales entry");
},
deep:true
}
},
But I have a store which is called like this
this.$store.dispatch(`${this.storeName}/updateNewShare`, this.newShareToken);
where this.storeName
is the name of the dynamic module. I can not use variables in watcher string. Can I?
Upvotes: 1
Views: 519
Reputation: 29179
Try to use the watch API from your mounted or created lifecycle.
mounted() {
store.watch(()=>`${this.storeName}/updateNewShare`, value=>{})
}
Upvotes: 1