Skip to content
This repository has been archived by the owner on Jan 11, 2023. It is now read-only.

Routing refactor #1434

Merged
merged 1 commit into from
Sep 18, 2020
Merged

Routing refactor #1434

merged 1 commit into from
Sep 18, 2020

Conversation

benmccann
Copy link
Member

@benmccann benmccann commented Aug 24, 2020

Closes #1431. This is a cleanup that separates out the navigation functionality into a standalone file

This does the following:

  • Renames start/index.ts to router/index.ts
  • Moves routing-related methods that were in app into router
  • Makes app import and instantiate router instead of the other way around

There are no user-visible changes in this PR. This PR looks big, but it's really just moved existing code and hasn't changed much at all. It would probably be hard to review the actual code to verify what's changed, but I hope the above provides a good summary. Since it's probably easier to review the description than the code, please let me know if you have questions

@ehrencrona
Copy link
Contributor

I hadn't looked much at app.ts before but this makes a lot of sense to me. The code feels a bit tangled at the moment and this is a good step in giving it more structure.

I did notice this doesn't quite disentangle the dependencies: router/index.ts depends on prefetch/index.ts which in turn depends on app.ts. I believe this is a code smell telling us that the prefetching should be moved (to prefetch/index.ts). This should be easy: two functions need to move and prefetch would also need an init.

Furthermore, I'm a bit worried by router not actually doing any routing. Maybe it makes sense in the longer term but for now I believe the name navigation might be more fitting.

@benmccann benmccann force-pushed the routing-refactor branch 2 times, most recently from 13c2b0c to a509dee Compare September 18, 2020 16:41
@benmccann
Copy link
Member Author

Agreed we could clean up prefetch a bit as well. That'd be a good follow up. I didn't want this one to get any bigger

My plan is to allow registering routes here as a next step. See sveltejs/rfcs#36 for more details on that. I figured it's better to leave this called router for now to avoid renaming multiple times and making this history harder to follow

Copy link
Member

@antony antony left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks very clean and isolates the router perfectly.

@benmccann benmccann merged commit a3635d2 into sveltejs:master Sep 18, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cleaner separation of router component
3 participants