Advertisement
Guest User

Untitled

a guest
Jul 23rd, 2019
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. import Vue from 'vue';
  2. import Vuex from 'vuex';
  3.  
  4. import mutations from './mutations';
  5. import * as actions from './actions'; // all actions are imported as separate vars
  6.  
  7. Vue.use(Vuex);
  8.  
  9. export default new Vuex.Store({
  10. state: { },
  11. mutations,
  12. actions
  13. });
  14.  
  15. import * as types from './mutation-types';
  16.  
  17. export const setFoo = ({ commit }, payload) => {
  18. commit(types.SET_FOO, payload); // SET_FOO is defined in the mutation-types file
  19. };
  20.  
  21. ...
  22. import actions from './actions'; // actions are imported as separate functions
  23. ...
  24.  
  25. import * as types from './mutation-types';
  26.  
  27. export default {
  28. [types.UPDATE_FOO] ({commit}, payload) {
  29. commit(types.UPDATE_FOO, payload);
  30. }
  31. }
  32.  
  33. store.dispatch(types.UPDATE_FOO, 'some value');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement