Skip to content

Commit

Permalink
Added persistent storage
Browse files Browse the repository at this point in the history
  • Loading branch information
pemcne committed Jun 7, 2018
1 parent c33b2d6 commit 0cffad9
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 2 deletions.
13 changes: 13 additions & 0 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
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
},
"dependencies": {
"vue": "^2.5.2",
"vuex": "^3.0.1"
"vuex": "^3.0.1",
"vuex-persist": "^1.4.0"
},
"devDependencies": {
"autoprefixer": "^7.1.2",
Expand Down
10 changes: 9 additions & 1 deletion src/store/index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
import Vue from 'vue'
import Vuex from 'vuex'
import VuexPersist from 'vuex-persist'

Vue.use(Vuex)

// Set up persistent storage
const vuexlocalstorage = new VuexPersist({
key: 'railway-simulator',
storage: window.localStorage
})

const state = {
money: 100,
workers: 0
Expand Down Expand Up @@ -48,5 +55,6 @@ export default new Vuex.Store({
state,
getters,
mutations,
actions
actions,
plugins: [vuexlocalstorage.plugin]
})

0 comments on commit 0cffad9

Please sign in to comment.