Vuex Structure (#8054)

* wip: vuex structure

* add missing files

* client: do not fail dev build on eslint error

* eslint does not block compilation, mount app when data is ready

* eslintrc.js -> eslintrc
This commit is contained in:
Matteo Pagliazzi
2016-09-23 19:49:11 +02:00
committed by GitHub
parent 5480157977
commit d3371e323e
12 changed files with 102 additions and 10 deletions

View File

@@ -4,16 +4,37 @@ require('babel-polyfill');
import Vue from 'vue';
import VuexRouterSync from 'vuex-router-sync';
import App from './components/app';
import VueResource from 'vue-resource';
import AppComponent from './components/app';
import router from './router';
import store from './vuex/store';
Vue.use(VueResource);
Vue.http.headers.common['x-api-user'] = '';
Vue.http.headers.common['x-api-key'] = '';
// Sync Vuex and Router
VuexRouterSync.sync(store, router);
new Vue({ // eslint-disable-line no-new
const app = new Vue({ // eslint-disable-line no-new
router,
store,
el: '#app',
render: h => h(App),
});
render: h => h(AppComponent),
mounted () { // Remove the loading screen when the app is mounted
let loadingScreen = document.getElementById('loading-screen');
if (loadingScreen) document.body.removeChild(loadingScreen);
},
});
// Setup listener for title that is outside Vue's scope
store.watch(state => state.title, (title) => {
document.title = title;
});
// Mount the app when the user is loaded
let userWatcher = store.watch(state => state.user, (user) => {
if (user && user._id) {
userWatcher(); // remove the watcher
app.$mount('#app');
}
});