When using the Vuex in VueJS, it can be useful to watch for changes in the store. To do so, you can make use of watch
method, like so :
|
|
This will watch the parameters
state key. Whenever it changes, the function from line 3 will be executed.
Note that you can also watch other things than directly the state, like getters for example :
|
|
You can put the watchers in the beforeCreate
lifecycle hook for example.