Skip to content

Commit

Permalink
Add support for centralized state management
Browse files Browse the repository at this point in the history
- Install vuex
  ``` bash
  npm add vuex
  ```

- Create `store.js` file in `src/` directory
  Register `vuex` plugin
  Expose a `Store` instance

- Use store in the application
  Add `store` to Vue constructor options
  • Loading branch information
znck committed Feb 1, 2018
1 parent 6185df4 commit 1f309bc
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 29 deletions.
63 changes: 35 additions & 28 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Expand Up @@ -7,7 +7,8 @@
"dependencies": {
"marked": "^0.3.12",
"vue": "^2.5.13",
"vue-router": "^3.0.1"
"vue-router": "^3.0.1",
"vuex": "^3.0.1"
},
"devDependencies": {
"@vue/cli": "^3.0.0-alpha.5",
Expand Down
2 changes: 2 additions & 0 deletions src/index.js
@@ -1,9 +1,11 @@
import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'

new Vue({
el: '#app',
router,
store,
render: h => h(App)
})
16 changes: 16 additions & 0 deletions src/store.js
@@ -0,0 +1,16 @@
import Vue from 'vue'
import Vuex, { Store } from 'vuex'

Vue.use(Vuex)

const getters = {}
const state = () => ({})
const mutations = {}
const actions = {}

export default new Store({
getters,
state,
mutations,
actions
})

0 comments on commit 1f309bc

Please sign in to comment.