hilongjw / vue-progressbar

A lightweight progress bar for vue
http://hilongjw.github.io/vue-progressbar
MIT License
1.46k stars 162 forks source link

How to use loading in vuex ajax loading #31

Open my9074 opened 7 years ago

my9074 commented 7 years ago

HI~

my most of Ajax was in the action of vuex,how to use loading in vuex ajax loading ?

const actions = {
  [type.FETCH_MOVIES] (context, payload) {
    api.fetchMovies(payload.type, {start: payload.start || 0})
      .then(data => context.commit(type.FETCH_MOVIES, {
        type: payload.type,
        subjects: data.subjects,
        total: data.total
      }))
  }
}
HKskn commented 7 years ago

I suggest you to use eventBus. Emit an event and listen it on the main.js

JoshuaDoshua commented 7 years ago

https://github.com/staskjs/vue-resource-progressbar-interceptor