Created
June 11, 2015 22:23
-
-
Save nhunzaker/635d693df4a0a85c7b87 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let Home = React.createClass({ | |
statics: { | |
fetch(app) { | |
return new Promise(function(resolve, reject) { | |
setTimeout(resolve, 1000) | |
}) | |
} | |
}, | |
render() { | |
return <p>Home</p> | |
} | |
} | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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