Calling Action when state property changes #1230
Unanswered
JokerMartini
asked this question in
Help and Questions
Replies: 1 comment
-
https://pinia.vuejs.org/introduction.html#basic-example
export const useToggle = defineStore("toggle", () => {
const toggle = ref(false);
const collapse = (v: boolean) => {
console.info("collapse", v);
};
watch(toggle, (t) => {
console.info("watch toggle", t);
collapse(t);
});
return {
toggle,
};
}); |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
What is the best way for me to trigger an action anytime a specific property has been changed within the state?
In this example the toggle property can be mutated from multiple places within the application. Any time toggle is mutated, i want to follow it up with executing the action toggleChanged. How would this be done? Ideally somehow within the state so the triggering is more easily manageable.
Beta Was this translation helpful? Give feedback.
All reactions