I'm working with Vue 3 and VueX.
I want to know if it's possible to check in computed if my returned value is true and than trigger my method directly without an watcher.
Info: this.$store.state.boolean is changing sometimes, so if it's true I want to trigger my method.
Below you can see an example how I'm doing it right now:
//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");
}
}
ifcondition inside the computed?test, you can do something like thisif (this.$store.state.boolean) { this.trigger_method() }