Created
May 17, 2017 04:02
-
-
Save israeleriston/c93284d8ed6325a8ad01861468390158 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
auth/store/plugins.js | |
import localforage from 'localforage' | |
import { userToken } from 'src/config' | |
import { setToken } from 'src/plugins/http' | |
import * as TYPES from './mutations-types' | |
const subscribe = (store) => { | |
store.subscribe((mutation, { auth }) => { | |
if (TYPES.SET_TOKEN === mutation.type) { | |
console.log(' subscribe ' + auth.token) | |
setToken(auth.token) | |
localforage.setItem(userToken, auth.token) | |
} | |
}) | |
} | |
export default (store) => { | |
subscribe(store) | |
} | |
/auth/store/index.js | |
import state from './state' | |
import * as getters from './getters' | |
import * as actions from './actions' | |
import mutations from './mutations' | |
import plugins from './plugins' | |
export default { state, getters, actions, mutations, plugins } | |
/src/store/plugins.js | |
import { store as app } from '../app' | |
export default { ...app.plugins } | |
/src/store/index.js | |
import Vue from 'vue' | |
import Vuex from 'vuex' | |
import * as actions from './actions' | |
import * as getters from './getters' | |
import state from './state' | |
import modules from './modules' | |
import mutations from './mutations' | |
import plugins from './plugins' | |
Vue.use(Vuex) | |
export default new Vuex.Store({ | |
state, | |
actions, | |
mutations, | |
getters, | |
modules, | |
plugins | |
}) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment