Skip to content

Commit af28c4e

Browse files
author
Bhanu Teja P
committed
Show loading dots whenever an action is performed
1 parent b495987 commit af28c4e

File tree

5 files changed

+17
-4
lines changed

5 files changed

+17
-4
lines changed

src/App.vue

-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
:active.sync="isLoading"
55
color="indigo"
66
loader="dots"
7-
opacity=0.4
87
is-full-page
98
></loading>
109
<Layout>

src/store/index.js

+3
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import Vue from 'vue';
44
import Vuex from 'vuex';
55

66
import authentication from './modules/authentication';
7+
import { Loading } from './plugins';
78

89
Vue.use(Vuex);
910

@@ -12,8 +13,10 @@ const debug = process.env.NODE_ENV !== 'production';
1213
const plugins = debug ? [
1314
createLogger(),
1415
// createPersistedState(),
16+
Loading,
1517
] : [
1618
createPersistedState(),
19+
Loading,
1720
];
1821

1922
export default new Vuex.Store({

src/store/plugins/index.js

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { default as Loading } from './loading';

src/store/plugins/loading.js

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
export default (store) => {
2+
store.subscribeAction({
3+
before: (action) => {
4+
console.log(`before action ${action.type}`);
5+
store.commit('setLoading', true, { root: true });
6+
},
7+
after: (action) => {
8+
console.log(`after action ${action.type}`);
9+
store.commit('setLoading', false, { root: true });
10+
},
11+
});
12+
};

vue.config.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@ module.exports = {
22
devServer: {
33
proxy: {
44
'/api': {
5-
target: 'https://localhost:8000',
6-
ws: true,
7-
changeOrigin: true,
5+
target: 'http://localhost:8000',
86
headers: {
97
Connection: 'keep-alive',
108
},

0 commit comments

Comments
 (0)