Vulcan/packages/nova-core/lib/containers/AppContainer.jsx

55 lines
1.1 KiB
React
Raw Normal View History

import React, { PropTypes, Component } from 'react';
const AppContainer = React.createClass({
2016-02-16 15:08:30 +09:00
mixins: [ReactMeteorData],
2016-02-16 15:08:30 +09:00
getMeteorData() {
2016-02-16 15:08:30 +09:00
var data = {
2016-02-23 11:34:40 +09:00
currentUser: Meteor.user(),
2016-02-16 15:08:30 +09:00
ready: false
};
2016-02-16 15:08:30 +09:00
var handles = Telescope.subscriptions.map((sub) => Meteor.subscribe(sub.name, sub.arguments));
2016-02-16 15:08:30 +09:00
if(!handles.length || _.every(handles, handle => handle.ready())) {
data.ready = true;
}
2016-02-16 15:08:30 +09:00
return data;
},
childContextTypes: {
2016-03-24 18:17:35 +09:00
currentUser: React.PropTypes.object,
currentRoute: React.PropTypes.object
},
getChildContext: function() {
2016-03-24 18:17:35 +09:00
FlowRouter.watchPathChange();
return {
currentUser: this.data.currentUser,
currentRoute: FlowRouter.current()
};
},
render() {
2016-02-16 15:08:30 +09:00
const Layout = Telescope.getComponent("Layout");
if (this.data.ready) {
2016-02-23 11:34:40 +09:00
return <Layout currentUser={this.data.currentUser}>{this.props.content}</Layout>
2016-02-16 15:08:30 +09:00
} else {
return <p>Loading App</p>
}
// return this.data.ready ? this.props.content : <Loading/>;
}
});
module.exports = AppContainer;
export default AppContainer;