Created
September 13, 2018 02:07
-
-
Save meshboy/70206204dcdb69868fb71e5e256aa7e6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Vue from 'vue'; | |
import Vuex from 'vuex'; | |
Vue.use(Vuex); | |
export const store = new Vuex.Store({ | |
state: { | |
counter: 0 | |
}, | |
getters: { | |
/** | |
* access counter in state from the paramater | |
*/ | |
addCurrencyToCounter: function (state) { | |
return `$ ${state.counter} (dollars)`; | |
}, | |
incrementCounterByTen: function(state) { | |
return state.counter + 10 | |
} | |
}, | |
mutations: { | |
increase: function(state) { | |
state.counter ++; | |
}, | |
decrement: function(state) { | |
state.counter++; | |
} | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment