Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import Vue from 'vue';
- import Vuex from 'vuex';
- import mutations from './mutations';
- import * as actions from './actions'; // all actions are imported as separate vars
- Vue.use(Vuex);
- export default new Vuex.Store({
- state: { },
- mutations,
- actions
- });
- import * as types from './mutation-types';
- export const setFoo = ({ commit }, payload) => {
- commit(types.SET_FOO, payload); // SET_FOO is defined in the mutation-types file
- };
- ...
- import actions from './actions'; // actions are imported as separate functions
- ...
- import * as types from './mutation-types';
- export default {
- [types.UPDATE_FOO] ({commit}, payload) {
- commit(types.UPDATE_FOO, payload);
- }
- }
- store.dispatch(types.UPDATE_FOO, 'some value');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement