-
Notifications
You must be signed in to change notification settings - Fork 21
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
server side rendering with multiple pages. #28
Comments
How about this? Your button.js exports a POJO (no rcss dependency), and the registration is done in the file requiring it (I guess for this part, we'd go back to the previous API). Redundant registration is ignored, naturally. One of the reason I avoided this is because I'd need to hash your POJO (probably |
@chenglou the problem is if i have a module using rcss i dont want to know about rcss when server side rendering nor do i want to know that i need to require that style and add it to the head. so we need some kind of server side rendering solution where it can somehow render itself efficiently without duplicating things. |
I think I can just duplicate the virtual node for the style for an rcss object in my tree. Then add an optimizing post processing step to remove duplicates at the top level. |
What if we had a separate API call,
This will admittedly only work with semi-static markup (because classes that aren't represented in the initial (@Raynos: I'm being sort of React-centric here because I know React makes it very easy to attain the HTML markup as a string, but from your superfine repo, it seems like it'd be easy to do with Mercury as well?) |
One of the approaches i was thinking was to have the rcss registry never clear itself. It's just a lookup table from class hash to style object. The way I would do the server side rendering is to walk my virtual tree and to ask RCSS for whats the style object for this hash. I.e. all I need is The biggest problem for me is the clearing of the registry. |
Yeah, that's an interesting idea. Two thoughts:
As a starting point (that we can tear down), I've pushed an (untested) revised API here. |
@crm416 I don't think you should clear the registry on the client. You should build two registries, one of all the RCSS objects registered and one of all the class names injected into the DOM already. Then when you call This way there are no race conditions. |
(Sorry, a bit busy this week, I'll be checking the convo and issues this weekend. Also, feel free to alter the API as I don't like the current one too much). |
@chenglou @crm416 if either of you are in bay area this weekend i dont mind doing a rcss hack day this weekend. |
I think that if you would use proper instances instead of a global object would fix this problem. Of course it would be more difficult to use (you need to keep track of your instance trough the app). So you might enable a global RCSS which works like how is working now.
Then you can allow people to instance RCSS:
But then you have to keep your myRCSS instance in order to render. Another idea is to use context. For example:
would register CSS on The problem can rise when some dependency of the app will use RCSS and you find unexpected CSS injected into your html... But that is another story. |
In issue #47 I comment that I like @bitplanets suggestion to allow page context more than using an object instance. I share his thought that separating pages in the code itself would simplify the problem. |
Let's imagine I'm building an app with
rcss
and want to do server side rendering.I have two simple pages
/
and/about
that have their own elements and styles.Because
rcss
has a global registry the call to.getStylesString()
would return the styles for both sites when I only want to insert the styles for a single page into that page.How do you imagine this approach scaling ? A component cannot have a notion of "what pages am I on". The top level page component somehow needs to say "for all" styles in my render call, insert them.
Not really sure how one would do that.
The text was updated successfully, but these errors were encountered: