Skip to content
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

feat(ssr): optionally render with app state #413

Closed
wants to merge 3 commits into from

Conversation

cdaringe
Copy link

@cdaringe cdaringe commented Feb 6, 2018

problem

solution

  • prototype api to allow user to provide app state to render with

discussion

im not married to this implementation at all, but i am eager for the feature, so i figured some code would get the convo rolling.

@cdaringe
Copy link
Author

cdaringe commented Feb 9, 2018

hi amigos, any time to poke at this yet? i really want to emphasize again that i'm ok with this PR being throw-away-ready if teamsters have different ideas. im just eager to get the feature in or on the roadmap! thx

@goto-bus-stop
Copy link
Member

Aye, thanks for the PR!

My first thought is that we probably need to know the route in an onPreRender like hook; so you can initialise different state for different pages.

IIRC the documentNode is only initialised once, so the hook would only be called the first time. Maybe we can have an API like this somehow?

var compiler = bankai(entry, opts)
compiler.documents('index.html', { initial: 'state' }, function () {})

Something else to consider is that we'd like to have async rendering in choo, so that you can do data loading inside the app before doing the server render. Work on that hasn't started yet but I think that might address some of the use cases for this feature too, like loading user data into state depending on the route. Doesn't mean we can't have both, especially if the choo feature is going to take some time

@cdaringe
Copy link
Author

cdaringe commented Feb 9, 2018

we probably need to know the route

agreed. 👍

compiler.documents('index.html', { initial: 'state' }, function () {})

ive been been hacking around on this for a bit now. im still not sure 100% how to best link all of this up.

it's as though we want each route that lands in the graph to also have an accompanying initial-state member in the graph as well. if we were to use compiler.documents(...) API you suggest, we may have to find a way to tap into the graph and change that initial-state Buffer. additionally, we would need to do something similar with a hook in the compiler options for the user to update that value, then render from the graph data in graph-document. it seems like if bankai wants to render from the graph, we should go full graph, and not have a mixed mode of getting input into the render pipeline, which was what i my PR was originally doing.

initial-state ➡️ graph. that sound right?

im a little stuck. maybe a 🚶 will help :)

@cdaringe cdaringe closed this Mar 6, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants