reduxjs/redux

A new Univeral app utility for Redux

ForbesLindesay opened this issue · 5 comments

I've built a small utility called redux-wait for helping to write universal redux apps. It relies on asynchronous middleware returning a promise for when the action has been handled, but if that's the case, it's pretty much a seamless transition from client side to universal.

I wrote up the steps I went through to convert the real-world example into a universal application in https://github.com/ForbesLindesay/redux-wait/tree/master/example It's also worth mentioning that step 1 can be removed if #537 is merged.

Would it be possible to add this to the "ecosystem" part of the docs?

How is this different than redux-promise?

@phated The idea here is that you can dispatch as any actions as you want - as long as they return a promise your application will not be rendered until all of them have been resolved. redux-promise on the other hand translates a returned promise into an action. So they can be use in conjunction.

@ForbesLindesay I'm curious though what the performance is for cascading actions, when you have to call React.renderToString multiple times on the server.

I'm not sure, that's definitely a good question. One thing I'd like to try is some sort of "render to undefined" that would do the render but ignore the results, then do one final render at the end.

If we did that we might also be able to fix the multiple calls to componentWillMount, which would allow the real-world example to work pretty much out of the box.

My feedback: it's better not to provide your own applyMiddleware. It's exactly the situation we had in #678 (comment): each helper wanting to “own” applyMiddleware isn't the right way.

For now, there is nothing actionable for Redux team here, the issue has been inactive for a while, so I'm closing. Thanks for sharing!