Vuejs 2 how to watch store values from vuex

78


16

I am using vuex and vuejs 2 together.

I am new to vuex, I want to watch a store variable change.

I want to add the watch function in my vue component

This is what I have so far:

import Vue from 'vue';
import {
  MY_STATE,
} from './../../mutation-types';

export default {
[MY_STATE](state, token) {
state.my_state = token;
},
};

I want to know if there are any changes in the my_state

How do I watch store.my_state in my vuejs component?

#vue-js

6 Likes64.20 GEEK