Refactor store management

This commit is contained in:
Lucas Verney 2017-09-22 09:51:24 -04:00
parent 8e49d0e0f2
commit 5ba15f8850
5 changed files with 5 additions and 15 deletions

View File

@ -20,10 +20,10 @@ export default {
}, },
computed: { computed: {
title() { title() {
return this.$store.getters.ui.title; return this.$store.state.ui.title;
}, },
backgroundColor() { backgroundColor() {
return this.$store.getters.ui.backgroundColor; return this.$store.state.ui.backgroundColor;
}, },
}, },
data() { data() {

View File

@ -44,7 +44,7 @@
<script> <script>
/** /**
* TODO: Do not open drawer on route change. * TODO: Do not open drawer on route change nor on resize.
* TODO: Should stick to the toolbar on xs screens. Should be fixed by Vuetify 0.16. * TODO: Should stick to the toolbar on xs screens. Should be fixed by Vuetify 0.16.
*/ */
export default { export default {

View File

@ -1,6 +0,0 @@
// TODO: Shouldn't we use mapState/mapGetters?
export default {
product: state => state.product,
isLoading: state => state.isLoading,
ui: state => state.ui,
};

View File

@ -1,9 +1,7 @@
import Vue from 'vue'; import Vue from 'vue';
import Vuex from 'vuex'; import Vuex from 'vuex';
import createLogger from 'vuex/dist/logger'; // TODO
import actions from './actions'; import actions from './actions';
import getters from './getters';
import { initialState as state, mutations } from './mutations'; import { initialState as state, mutations } from './mutations';
Vue.use(Vuex); Vue.use(Vuex);
@ -11,7 +9,5 @@ Vue.use(Vuex);
export default new Vuex.Store({ export default new Vuex.Store({
state, state,
actions, actions,
getters,
mutations, mutations,
plugins: [createLogger()],
}); });

View File

@ -67,12 +67,12 @@ export default {
}, },
computed: { computed: {
product() { product() {
const product = this.$store.getters.product; const product = this.$store.state.product;
this.$store.dispatch('setTitle', { title: product.product_name }); this.$store.dispatch('setTitle', { title: product.product_name });
return product; return product;
}, },
isLoading() { isLoading() {
return this.$store.getters.isLoading; return this.$store.state.isLoading;
}, },
}, },
methods: { methods: {