Skip to content

Commit

Permalink
add and configure vuex-persist as a plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
pixeldesu committed Jan 25, 2020
1 parent 7b482ea commit 4cefa02
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 3 deletions.
17 changes: 15 additions & 2 deletions package-lock.json

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

8 changes: 7 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"vue": "^2.6.10",
"vuetify": "^2.1.0",
"vuex": "^3.1.2",
"vuex-persist": "^2.2.0",
"xml2js": "^0.4.23"
},
"devDependencies": {
Expand Down Expand Up @@ -48,7 +49,12 @@
"airbnb-base"
],
"rules": {
"no-param-reassign": ["error", { "props": false }]
"no-param-reassign": [
"error",
{
"props": false
}
]
},
"parserOptions": {
"parser": "babel-eslint"
Expand Down
2 changes: 2 additions & 0 deletions src/store/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@ import Vuex from 'vuex';
import actions from './actions';
import mutations from './mutations';
import state from './state';
import persistence from './persistence';

Vue.use(Vuex);

export default new Vuex.Store({
state,
mutations,
actions,
plugins: [persistence.plugin],
});
15 changes: 15 additions & 0 deletions src/store/persistence.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import VuexPersistence from 'vuex-persist';

const ALLOWED_MUTATIONS = [
'TOGGLE_DRAWER',
'SELECT_CHANNEL',
];

export default new VuexPersistence({
storage: window.localStorage,
reducer: (state) => ({
drawer: state.drawer,
selectedChannel: state.selectedChannel,
}),
filter: (mutation) => ALLOWED_MUTATIONS.includes(mutation.type),
});
1 change: 1 addition & 0 deletions vue.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
module.exports = {
transpileDependencies: [
'vuetify',
'vuex-persist',
],
pwa: {
name: 'videoline',
Expand Down

0 comments on commit 4cefa02

Please # to comment.