Answers for "vuex store watch"

0

vuex store watch

import { mapState } from 'vuex';

export default {
    computed: {
        ...mapState(['somestate']),
        someComputedLocalState() {
            // is triggered whenever the store state changes
            return this.somestate + ' works too';
        }
    },
    watch: {
        somestate(val, oldVal) {
            // is triggered whenever the store state changes
            console.log('do stuff', val, oldVal);
        }
    }
}
Posted by: Guest on March-16-2022
0

vuex store watch

watch: {
  '$store.state.drawer': function() {
    console.log(this.$store.state.drawer)
  }
}
Posted by: Guest on March-16-2022
0

vuex store watch

computed: {
    ...mapState({
        // to access local state with `this`, a normal function must be used
        countPlusLocalState (state) {
          return state.count + this.localCount
        }
    }
})
Posted by: Guest on March-16-2022

Code answers related to "Javascript"

Browse Popular Code Answers by Language