I'm currently working on a project using Vue 3
along with VueX
.
I am wondering if there is a way to check within the computed
property whether the value returned
is true
, and then directly trigger my method
without needing a watcher.
A bit of background: The value of this.$store.state.boolean
changes occasionally, so I need to trigger my method if it becomes true
.
Below is an example of how I am currently handling this:
//computed
computed: {
test() {
return this.$store.state.boolean;
},
}
//watch
watch: {
test(boolean) {
if (boolean == true) {
this.trigger_method();
}
}
},
//methods
method: {
trigger_method() {
console.log("TEST");
}
}