parsley/app/javascript/lib/GlobalMixins.js

31 lines
536 B
JavaScript
Raw Normal View History

2018-03-30 14:31:09 -05:00
import Vue from 'vue';
2018-03-30 17:08:09 -05:00
import { mapGetters, mapMutations, mapState } from 'vuex';
2018-03-30 14:31:09 -05:00
Vue.mixin({
computed: {
2018-03-30 17:08:09 -05:00
...mapGetters([
"isLoading",
2018-04-01 12:17:54 -05:00
"isLoggedIn",
"isAdmin"
2018-03-30 17:08:09 -05:00
]),
...mapState([
"user"
])
2018-03-30 14:31:09 -05:00
},
methods: {
...mapMutations([
'setError',
'setLoading'
]),
loadResource(promise, successFunc) {
this.setLoading(true);
return promise
.then(successFunc)
.catch(err => this.setError(err))
.then(() => this.setLoading(false));
}
}
});