Skip to content

Questions & Feedback about h0 #3

@mmocny

Description

@mmocny

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 vs route() seems confusing to me.

    • It is my understanding that scope dictates which template file is used to serve a given request, and that seems like the primary job of a "router".
    • It is my understanding that route() maps a Request to a ViewModel, and that seems like the primary job of a "loader".
    • If that is correct, I think it would be clearer to rename these accordingly.
  • 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?

    • Is this a fundamental opinion of h0 or just a detail of current implementation?
    • I think this is not the typical definition of SPA and could be clarified in the docs.
    • I don't think it's a bad idea to separate when to go back just for data vs when to go back for HTML... but I think the way it currently works risks bloating the initial 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...

    • this is a neat idea, but it may be useful to make this pattern cleaner for typical cases...
    • Is it expected that h0 should support non-SSR, where route() must be able to run on client? I feel this is already not true for some of the examples...
    • If not, consider making route() always "server-only", and then having a separate, optional function that can run on client as well, perhaps interceptRoute().
    • when implemented, interceptRoute() would either return its own Response or fallback to return route(request). On client, the default route() 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 and render() 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?

    • There are some existing novel techniques to do this...
  • 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().

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions