parsley/app/javascript/lib/GlobalMixins.js

30 lines
496 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'
]),
2018-04-01 21:43:23 -05:00
loadResource(promise) {
2018-03-30 14:31:09 -05:00
this.setLoading(true);
return promise
.catch(err => this.setError(err))
.then(() => this.setLoading(false));
}
}
});