4 ms·
I'm also experimenting with "isomorphic" apps. I wrote a router with an expressjs/hapijs like API (middlewares included). The main point is handling the state b
by gcanti 12y ago
I'm also experimenting with "isomorphic" apps. I wrote a router with an expressjs/hapijs like API (middlewares included). The main point is handling the state before choosing the view. The concept is general enough to avoid being tied to React although React makes things easier. Once you have such a router, handling nested views (a la react-router) is a trivial particular case.
Here's my lab https://github.com/gcanti/tom https://github.com/gcanti/tom
- skrebbel 12y agoI'm interested! I can't find your main point back in your examples, however - I need to be able to asynchronously get data from all kinds of places before I can even think about calling React.renderToString. Does tom allow that? If so, what am I missing?
- gcanti 12y ago> I need to be able to asynchronously get data from all kinds of places before I can even think about calling React.renderToString You can define middlewares, as you would do server-side with expressjs: router.route({ method: 'GET', path: '/users/:userId', handler: function (ctx) { // load user async getUser(ctx.params.userId, function (err, user) { ctx.user = user; ctx.next(); // exec next middleware }); } }); There is a `demo` folder with a detailed example. The main entry point for the client is here https://github.com/gcanti/tom/blob/master/demo/client.js#L21 https://github.com/gcanti/tom/blob/master/demo/client.js#L21
- skrebbel 12y agoThanks! No express experience so the term didn't mean anything to me. My understanding of the word "middleware" is "well, it has no UI and it isn't a database or robot arm either, but we don't really know what it is either".