Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

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);
        }
    }
}
Comment

vuex store watch

watch: {
  '$store.state.drawer': function() {
    console.log(this.$store.state.drawer)
  }
}
Comment

vuex store watch

computed: {
    ...mapState({
        // to access local state with `this`, a normal function must be used
        countPlusLocalState (state) {
          return state.count + this.localCount
        }
    }
})
Comment

PREVIOUS NEXT
Code Example
Javascript :: js copy text 
Javascript :: cancel an event in javascript 
Javascript :: Update select2 after removing an element 
Javascript :: jquery append after number of chars in string 
Javascript :: convery array of objects to map using immutables js 
Javascript :: date.gettime is not a function 
Javascript :: jspdf reduce size file 
Javascript :: update array of objects with use state 
Javascript :: autocomplete react jsx attributes vscode 
Javascript :: react concatenate string and component 
Javascript :: iterate loop over mapping in solidity 
Javascript :: js object sort 
Javascript :: pass data from child component to parent component 
Javascript :: how to add new line in jsx 
Javascript :: get form data in js 
Javascript :: dynamic set required in angular using formcontrol 
Javascript :: javascript timestamp conversion 
Javascript :: accepting form data node js 
Javascript :: arrow functions in js 
Javascript :: socket.id 
Javascript :: Discord.js Get A Bot To Join A Music Chanel 
Javascript :: create audio tag javascript 
Javascript :: vue js encrypt localstorage data 
Javascript :: cors axios 
Javascript :: puppeteer js headless mode 
Javascript :: Icons library in react 
Javascript :: js base64 encode 
Javascript :: import npm module node.js 
Javascript :: check if the difference between two dates is more than 1 month in javascript 
Javascript :: javascript import class 
ADD CONTENT
Topic
Content
Source link
Name
9+3 =