Last active
April 30, 2020 08:30
-
-
Save pipopotamasu/58340b47687be3468ba3e3c0ad116418 to your computer and use it in GitHub Desktop.
store injection
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
import FooService from '@js/services/FooService'; | |
import BarService from '@js/services/BarService'; | |
export default function createApi (dispatch: Dispatch) { | |
return { | |
foo: new FooService(dispatch), | |
bar: new BarService(dispatch) | |
} | |
} |
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
import Vue from 'vue'; | |
import Vuex from 'vuex'; | |
import createApi from '@js/store/createApi'; | |
import Auth from '@js/store/modules/auth'; | |
import Todo from '@js/store/modules/todo'; | |
Vue.use(Vuex); | |
const store = new Vuex.Store<any>({ | |
modules: { | |
auth: Auth, | |
todo: Todo, | |
} | |
}); | |
store.$api = createApi(store.dispatch); | |
export default store; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment