Vulcan/packages/nova-core/lib/containers/AppContainer.jsx
2016-03-24 18:17:35 +09:00

55 lines
No EOL
1.1 KiB
JavaScript

import React, { PropTypes, Component } from 'react';
const AppContainer = React.createClass({
mixins: [ReactMeteorData],
getMeteorData() {
var data = {
currentUser: Meteor.user(),
ready: false
};
var handles = Telescope.subscriptions.map((sub) => Meteor.subscribe(sub.name, sub.arguments));
if(!handles.length || _.every(handles, handle => handle.ready())) {
data.ready = true;
}
return data;
},
childContextTypes: {
currentUser: React.PropTypes.object,
currentRoute: React.PropTypes.object
},
getChildContext: function() {
FlowRouter.watchPathChange();
return {
currentUser: this.data.currentUser,
currentRoute: FlowRouter.current()
};
},
render() {
const Layout = Telescope.getComponent("Layout");
if (this.data.ready) {
return <Layout currentUser={this.data.currentUser}>{this.props.content}</Layout>
} else {
return <p>Loading App</p>
}
// return this.data.ready ? this.props.content : <Loading/>;
}
});
module.exports = AppContainer;
export default AppContainer;