Skip to content

Instantly share code, notes, and snippets.

@DeVoresyah
Created July 6, 2020 18:58
Show Gist options
  • Save DeVoresyah/335224a670ed1e9ddd6d104958803094 to your computer and use it in GitHub Desktop.
Save DeVoresyah/335224a670ed1e9ddd6d104958803094 to your computer and use it in GitHub Desktop.
import createPersistedState from 'vuex-persistedstate'
import * as Cookies from "js-cookie";
let cookieStorage = {
getItem: function(key) {
return Cookies.getJSON(key);
},
setItem: function(key, value) {
return Cookies.set(key, value, {expires: 3, secure: false});
},
removeItem: function(key) {
return Cookies.remove(key);
}
};
export default ({store}) => {
createPersistedState({
key: 'resweepy',
storage: cookieStorage,
getState: cookieStorage.getItem,
setState: cookieStorage.setItem,
reducer: (state) => ({ session: state.session })
})(store)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment