feat(history-sync): add `priority` option to routes
Please check the added test suite to see the expected behavior!
🦋 Changeset detected
Latest commit: 916185d4d97c2cf283a8764d6f6ac428fa54460c
The changes in this PR will be included in the next version bump.
This PR includes changesets to release 1 package
| Name | Type |
|---|---|
| @stackflow/plugin-history-sync | Minor |
Not sure what this means? Click here to learn what changesets are.
Click here if you're a maintainer who wants to add another changeset to this PR
The latest updates on your projects. Learn more about Vercel for Git ↗︎
| Name | Status | Preview | Updated (UTC) |
|---|---|---|---|
| stackflow-docs | ✅ Ready (Inspect) | Visit Preview | Nov 16, 2024 6:17am |
Our team has been thinking about this issue before, and we thought of several candidates for the acceptable priority rule.
- Users set their own path priorities (This PR's way)
- Indirect reflection in the order of declaration (vue router)
- Score calculation (react router, current way)
Which method do you think is the best?
Although I also believe that the score calculation should be the default behavior in most cases, I found that it sometimes makes sense to override this and therefore made this PR, which works as a hybrid of 1 and 3. I prefer my solution the most since it provides both a good default and an escape hatch that can be utilized in advanced use cases.
Although I also believe that the score calculation should be the default behavior in most cases, I found that it sometimes makes sense to override this and therefore made this PR, which works as a hybrid of 1 and 3. I prefer my solution the most since it provides both a good default and an escape hatch that can be utilized in advanced use cases.
Oh, I see. Is there an example that requires an escape hatch against score rule?
My use case was dynamically matching splat routes in runtime and falling back to the default route-matching algorithm when no match was found. It was for keeping the URLs simple while using https://github.com/contentstech-com/stackflow-plugin-omniflow and also utilized #535 to appropriately transform activity params to a URL. I can also share a code snippet for dynamic route matching if you need to see that.