Usage inside vue-resource interceptor
Hi, I'm using vue-resource and I'd like to use vue-spinner inside interceptors to show/hide the spinner on any ajax request. I don't know if it's possible to reference a vue-spinner component inside the interceptor. I have done the following but with no success: (I'm using vueify)
var PulseLoader = require('vue-spinner/dist/vue-spinner.min').PulseLoader;
Vue.http.interceptors.push((request, next) => {
this.loading = true;
next((response) => {
this.loading = false;
});
});
new Vue({
el: '#grid-manager',
components: { 'pulse-loader': PulseLoader},
....and in the root vue instance i have:
<pulse-loader :loading="loading" :color="color" :size="size"></pulse-loader>
Thanks!
Did you get this figured out?
Not yet @patrickbolle I think i'm going to use other options like this one http://ricostacruz.com/nprogress/
I guess this in the interceptor is in context of interceptor, not the vue main instance.
a good solution is to use a global mixin like
Vue.mixin({
data() {
return {
loading: false
}
}
})
then loading is a reactive property and can be used in interceptors