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

Vision for client-side routing? #4

Open
achou11 opened this issue Apr 3, 2022 · 2 comments
Open

Vision for client-side routing? #4

achou11 opened this issue Apr 3, 2022 · 2 comments

Comments

@achou11
Copy link
Contributor

achou11 commented Apr 3, 2022

Have you had any ideas on how client-side routing would work in yeet? Would it be something that can be implemented in yeet itself or would you defer to some other library/implementation? Would an in-house implementation be similar to how Choo works?

For me, I feel like that's the last missing piece of making yeet something I can be productive with when it comes to building SPAs, so just curious if there were any thoughts on that

@tornqvist
Copy link
Owner

My thinking is to keep yeet as lean as possible and to rely on external libraries for most of the application orchestration. It makes it easier to iterate on concepts without worrying about breaking changes. Ideally even the components would be external but atm. the rendering needs to be aware of how to handle the components. I should say though that I have a rewrite in the works which improves first reder (by a lot) and also does isolate the components a bit more from the core, though not completely.

Regarding the router, I have been sketching on an idea similar to the router in Choo which works like a Ref where you get the current resolved route on a router instance. This would allow for routers to be used by any component at any depth of the application and one could even implement nested routing. Let me know what you think.

import { html, Component } from 'yeet'
import { Router } from 'yeet-router' // or whatever

export default Component(function (state, emit) {
  const router = new Router()

  router.on('/foo', () => import('./foo.js'))
  router.on('/bar', () => html`<div>bar</div>`)
  router.on('/baz', () => Component((state) => html`<div>${state.baz}</div>`))

  return function () {
    return html`
      <div id="app">
        ${router.current}
      </div>
    `
  }
})

@achou11
Copy link
Contributor Author

achou11 commented Apr 6, 2022

thanks for the explanation! very cool to know that you're iterating on ideas and personally super excited to see how it materializes. regarding the router, looks solid to me! being able to nest routing is definitely a big plus :)

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

No branches or pull requests

2 participants