30 lines
519 B
JavaScript
30 lines
519 B
JavaScript
|
|
import Vue from 'vue';
|
|
import { mapGetters, mapMutations, mapState } from 'vuex';
|
|
|
|
Vue.mixin({
|
|
computed: {
|
|
...mapGetters([
|
|
"isLoading",
|
|
"isLoggedIn"
|
|
]),
|
|
...mapState([
|
|
"user"
|
|
])
|
|
},
|
|
methods: {
|
|
...mapMutations([
|
|
'setError',
|
|
'setLoading'
|
|
]),
|
|
|
|
loadResource(promise, successFunc) {
|
|
this.setLoading(true);
|
|
|
|
return promise
|
|
.then(successFunc)
|
|
.catch(err => this.setError(err))
|
|
.then(() => this.setLoading(false));
|
|
}
|
|
}
|
|
}); |