-
Notifications
You must be signed in to change notification settings - Fork 188
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Async rendering and Aphrodite #245
Comments
This has already been discussed a little bit in #63. In order to render styles that the page needs in the Random thought, though: We might be able to get away with rendering |
Yes, adding support for streaming will definitely be a challenge. Async rendering isn't just streaming though, rapscallion supports rendering to a promise but we'd need Aphrodite to support multiple injection buffers on the server in that case so that they don't clobber each other. |
This might be tangentially related: We call the We've currently forked Aphrodite so we could use |
Can we start a conversation around what it's going to take to make streaming support a reality? It looks like we're coming closer and closer to a reality where people building React applications are going to want it. As @goatslacker mentioned:
Is multiple injection buffers something that the maintainers of Aphrodite actually want to support with this project in the future? If so, it would be very helpful to have some guidance around what this should look like. |
I find myself in need of async rendering support as well. I am working with an asynchronous router (universal-router) that basically resolve routes to components asynchronously. The Example:
Here is the rendering function (it resolves the route and then wrap it up in an component that know show to inject scripts, css, and so on:
The problem I am facing is this: I can't call Passing in my whole render function to Aphrodite doesn't work either because it is asynchronous: Now if I understand this thread and the code correctly, simply updating |
I'm hitting this issue as well. When two requests come in at the same time, they step on each other. As long as the requests are simultaneous, I'm consistently getting I'm using |
Hi all, I have a working solution for this and could make a PR, but are PRs even looked at? |
Always better to file it and have it ignored, then never file it just in case it might be ignored :-) |
Done :P #390 |
Aphrodite currently relies on the fact that rendering with React is synchronous in order to build up/pull out the css definitions. The
injectionBuffer
is actually a module level "global" that just gets appended to: https://github.com/Khan/aphrodite/blob/master/src/inject.js#L140While this works great at the moment, asynchronous rendering of React components are going to become popular in the near future and libraries like this will need to adapt.
Putting this issue on your radar so we can discuss how we'd go about safely living in an async world.
There already exists a few implementations that either stream, or render to a promise:
https://github.com/aickin/react-dom-stream
https://github.com/FormidableLabs/rapscallion
The text was updated successfully, but these errors were encountered: