parsley/app/javascript/lib/GlobalMixins.js
2018-03-30 17:08:09 -05:00

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));
}
}
});