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

Roadmap v4 #19

Open
1 of 9 tasks
mefechoel opened this issue Oct 13, 2020 · 2 comments
Open
1 of 9 tasks

Roadmap v4 #19

mefechoel opened this issue Oct 13, 2020 · 2 comments

Comments

@mefechoel
Copy link
Owner

mefechoel commented Oct 13, 2020

V4 should make the router usable for more use cases. I've been planing on adding a hash based history for a while now. But there are a few things standing in the way to do this properly. Although the hash history would be optional, you'd still need the default browser history, as well as the fallback memory history module, even though you'd never use them. I've setup a new repo, where the history modules will be developed (svelte-navigator-history).
As a result the Router API will need to change slightly. There will need to be different Routers, like a HashRouter and BrowserRouter, similar to react-routers API. That's the only way to not bundle all history modules for every project.

In more detail, for v4 I'm planning to finish these tasks:

  • Add more tests to ensure everything is still working as intended
  • Add Router modules that are bound to a specific history
    • BrowserRouter using the HTML5 History API
    • HashRouter using the hash fragment
    • MemoryRouter for testing and embedded widgets
    • A Router, that automatically falls back to a memory history when the browser history doesn't work. Maybe AutoRouter
  • Add a way to block navigation, so the loss of unsaved data can be prevented
  • Make it possible to force a nested Router to act as a top-level Router, so it can be used to control a single widget on the page
  • Write a migration guide (also for people coming from svelte-routing Is there any migration guide for Svelte-routing? #13)
@mefechoel mefechoel pinned this issue Oct 13, 2020
mefechoel added a commit that referenced this issue Oct 17, 2020
@guidobouman
Copy link

Do you not want to use https://github.com/ReactTraining/history ? The underlying history handler for react-router. Seems like that would take the issues out of routing, and focus on the actual value for svelte.

@mefechoel
Copy link
Owner Author

I've thought about it and I might switch to it in the future or during the development of v4. It also already implements blocking, so that would be a benefit as well.

I didn't do it for now because it handles a few things a little differently. It parses locations slightly differently and it does not implement the svelte store interface, so I'd need to write a wrapper for svelte-navigator. It was also kind of fun do build the module myself...

I guess it would be more maintainable to rely on the history package going forward, but I'll try to finish the v4 api first and then see if I'll switch the history module...

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