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

feat(history-sync): add priority option to routes #536

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

XiNiHa
Copy link
Contributor

@XiNiHa XiNiHa commented Nov 16, 2024

Please check the added test suite to see the expected behavior!

Copy link

changeset-bot bot commented Nov 16, 2024

🦋 Changeset detected

Latest commit: 916185d

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

Copy link

vercel bot commented Nov 16, 2024

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

@orionmiz
Copy link
Member

orionmiz commented Dec 10, 2024

Our team has been thinking about this issue before, and we thought of several candidates for the acceptable priority rule.

  1. Users set their own path priorities (This PR's way)
  2. Indirect reflection in the order of declaration (vue router)
  3. Score calculation (react router, current way)

Which method do you think is the best?

@orionmiz orionmiz self-requested a review December 10, 2024 08:38
@XiNiHa
Copy link
Contributor Author

XiNiHa commented Dec 10, 2024

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.

@orionmiz
Copy link
Member

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?

@XiNiHa
Copy link
Contributor Author

XiNiHa commented Dec 10, 2024

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.

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

Successfully merging this pull request may close these issues.

2 participants