Skip to content

Instantly share code, notes, and snippets.

@pipopotamasu
Last active April 30, 2020 08:30
Show Gist options
  • Save pipopotamasu/58340b47687be3468ba3e3c0ad116418 to your computer and use it in GitHub Desktop.
Save pipopotamasu/58340b47687be3468ba3e3c0ad116418 to your computer and use it in GitHub Desktop.
store injection
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)
}
}
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