Skip to content

Instantly share code, notes, and snippets.

/module.js Secret

Created January 10, 2018 17:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/18580b1fef1a5c9b8ad87a377baaf07d to your computer and use it in GitHub Desktop.
Save anonymous/18580b1fef1a5c9b8ad87a377baaf07d to your computer and use it in GitHub Desktop.
import Vue from 'vue'
import * as types from '../mutation_types'
const testModule = {
state: {
username: null
},
actions: {
fetchUserInfo ({commit}) {
commit(types.PENDING);
return new Promise((resolve) => {
commit(types.SET_USER, 'Unodepiera');
resolve('Unodepiera');
commit(types.NOT_PENDING);
});
}
},
mutations: {
[types.SET_USER]: (state, response) => {
state.username = response; // Unodepiera
}
},
getters: {
username: (state) => {
return state.username;
}
}
}
export default testModule
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment