I want to trigger a method(serviceSelected) when state of a variable changes. I am trying to use computed but it is not working. My variable is in vuex store which is having a getter as getServiceSelected
computed: {
...mapGetters(["getServiceSelected"]),
serviceChanged() {
this.serviceSelected(this.getServiceSelected);
return this.getServiceSelected
}
}
Use watch
er instead
computed: {
...mapGetters(["getServiceSelected"])
},
watch: {
getServiceSelected(newValue, oldValue) {
// do something
this.serviceSelected(newValue);
}
}