Using a watcher decorator in a Vuex store with Typescript

107 Views Asked by At

I have a getter on a Vuex store called storeOne (not namespaced) :

public get IsHistoricMode(): boolean {
    return this.historicMode;
}

I have another store called storeTwo (namespaced). I tried to track state changes from "IsHistoricMode" getter with a watcher :

@Getter('IsHistoricMode')
private isHistoricMode!: boolean;

@Watch('isHistoricMode')
private historicModeChange() {
    console.log("historicMode changed !");
}

If I mutate the value HistoricMode in storeOne. My watcher in storeTwo is never triggered.

It seems possible to use a watcher in Vuex : https://vuex.vuejs.org/api/#watch.

The npm packages used are :

  • Vue 2.6.14
  • Vuex 3.6.2
  • TypeScript 3.1.1
  • vuex-module-decorators 0.9.11
  • vuex-class 0.3.2

Could you help us please ?

Thank you

0

There are 0 best solutions below