-
Notifications
You must be signed in to change notification settings - Fork 8
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
Questions & Feedback about h0 #3
Comments
Thanks, and thanks for all the detailed feedback! Detailed feedback is my favourite.
Think of scope as the root route for the whole app, something like
It also does the same as an express
Yes. The idea is that you share a template for client-side rendering, and do the app-specific thing inside
It's a fundamental starting point. The idea is in the name - h0 (html first). So your HTML is the first source of truth for your entire app. Also implementation-wise,
I don't follow. How I understand "SPA" is that forms and links within your app don't mandate a refresh. It's perhaps not the typical nextjs-like implementation of SPA. Is that what you mean?
You don't "go back for HTML". Your client.js should be pretty small exactly because it doesn't include HTML - it includes only changes - how dynamic content is injected into the DOM. I can see a future though where part of your
Agreed, didn't get to it yet.
Yes, the TODOs example only works with client-side routing because the "backend" is
Right now you do that by adding
Yea that would be a good addition, I wanted to run a bit with the "basic" which uses the
Correct. There is no "framework state" (well, apart from a few attributes that help with list reconciliation) so there is no "hydration" except for adding event listeners etc.
Sounds like a bug in the docs.
I thought about this originally, let me explain why I went without it. "Applying the delta locally" means
Or do you mean something like existing VDOM/htmldiff libraries? I thought that running
I'd love to use the navigation APIs and considered it, but the polyfills don't support the
Yay, thanks!
Hmm did I say they were bad? I said they were "magic" and I wanted to offer a tradeoff that opts out of magic. |
Ah, thats funny. I was using the terms in the way js frontend naming use them, but it seems backends/express overload these as well. I don't have enough experience with express to grok the naming conventions.
I was using In remix, loader() is generates the data (ViewModel) for a specific route, and it is used in
This we agree on, but... With h0 it seems you have 2 options:
This is why I say that h0 does not seem like an SPA to me, even though it has some ability for client-side interactive updates. I think that it could easily change, tho, if you just supported SPA transitions between Another concept that may help is the idea of "(nested) layouts". Some "routes" share most of the UI (layout) even though the data source differs slightly (i.e. Movies App UI uses the same layout for different filters). Maybe Just my 2cents!
Not vdom, just dom diff (like htmx or hotwire/turbo). It lets you transition between MPA pages with SPA behaviours, without having to manage the whole site as a giant component tree. I think it would be a good potential fit for transitioning between scopes. On the one hand, its just an optimization of MPA transitions -- but perhaps it would enable you to split your HTML templates into more fine grained routes... |
Ah I see the misunderstanding. route() is not always sent to the client. The author decides that based on the RUNTIME global, letting the minifier fold that code. That's the concept at least, it's not well documented yet. What's always sent to the client is the render function. |
OK, I think
So the idea is that route() in most cases is on the server, and render() can have dynamic imports if you so choose (but it's not part of the framework). |
OK made some changes to reflect these comments:
|
You touched on the exact point of h0. The idea is that if the app is simple enough to be sent to the client as a single HTML, then it's simple enough to be authored as a "master" HTML template (with includes, modules, web components etc to make it easier). If it gets more complicated, maybe it's time to MPA it? |
Huzzah! Thanks for the quick answers. |
Fun project! :D
I figured I would leave some comments after reading the README.md, going through some examples, and reading a bit of the source for the first time:
The concept of
scope
vsroute()
seems confusing to me.scope
dictates which template file is used to serve a given request, and that seems like the primary job of a "router".route()
maps a Request to a ViewModel, and that seems like the primary job of a "loader".It looks to me like you will always hard navigate across different
scope
, and that re-rendering client-side only works if it shares a template?client.js
payload to include the whole application, effectively, to gain SPA behaviours.Looking at some examples, it seems
route()
is always sent to client. It's up to the application to decide when to run on client or to go back to server...route()
always "server-only", and then having a separate, optional function that can run on client as well, perhapsinterceptRoute()
.interceptRoute()
would either return its own Response or fallback toreturn route(request)
. On client, the defaultroute()
implementation would just be fetch.I'm happy to see a simple
mount()
helper. I suspect that this is the only function that runs on client in the case of SSR? I.e. there is no need to re-render the initial UI on the client, right?If run in "SPA mode", docs suggest that
route()
is called only once on the server andrender()
is called any number of times on the client -- but I think its always 1:1, right? Or is there something that could force a re-render on the client without a data fetch?In a future update, would it be possible to run
render()
on server and return the HTML to the client, and apply a delta locally instead?Would you consider implementing client-routing with the new Navigation API, which has polyfills and offers some advantages? I don't know if there is a version that runs on server...
That's it for now :P
Generally, I like the simplicity & structure.
I'm not sure I'm quite with you RE: "declarative and reactive is bad", but I think it's nice to have framework that opts-out of that part. Would be interesting to experiment with layering view-only libraries into your
render()
.The text was updated successfully, but these errors were encountered: