Skip to content

Instantly share code, notes, and snippets.

@nhunzaker
Created June 11, 2015 22:23
Show Gist options
  • Save nhunzaker/635d693df4a0a85c7b87 to your computer and use it in GitHub Desktop.
Save nhunzaker/635d693df4a0a85c7b87 to your computer and use it in GitHub Desktop.
let Home = React.createClass({
statics: {
fetch(app) {
return new Promise(function(resolve, reject) {
setTimeout(resolve, 1000)
})
}
},
render() {
return <p>Home</p>
}
}
const app = new App()
const target = document.querySelector("#app")
app.start(function() {
Router.run(function(Handler, state) {
let { query, params, routes } = state
let requests = state.routes.filter(i => i.handler.fetch)
.map(i => i.handler.fetch(app, params, query))
Promise.all(requests).then(function() {
React.render(<Handler { ...state } app={ app } />, target)
})
})
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment