Skip to content

Instantly share code, notes, and snippets.

@davidalves1
Forked from IgorHalfeld/vuejs-simple-store.js
Created April 24, 2020 03:01
Show Gist options
  • Save davidalves1/fa7b6046865512ae5f8480174f3d8238 to your computer and use it in GitHub Desktop.
Save davidalves1/fa7b6046865512ae5f8480174f3d8238 to your computer and use it in GitHub Desktop.
function createStore({ state, mutations }) {
return {
state: Vue.observable(state),
commit(key, ...args) {
mutations[key](state, ...args)
}
}
}
const store = createStore({
state: { count: 0 },
mutations: {
inc (state) {
state.count++
}
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment