import Vue from 'vue'; import { mapMutations, mapState } from 'vuex'; Vue.mixin({ computed: { ...mapState({ isLoading: state => state.loading }) }, methods: { ...mapMutations([ 'setError', 'setLoading' ]), loadResource(promise, successFunc) { this.setLoading(true); return promise .then(successFunc) .catch(err => this.setError(err)) .then(() => this.setLoading(false)); } } });