-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Rewrite router #1791
Rewrite router #1791
Conversation
Visit the preview URL for this PR (updated for commit d664037): https://yew-rs--pr1791-router-rewrite-mjf0m3ps.web.app (expires Mon, 24 May 2021 11:04:28 GMT) 🔥 via Firebase Hosting GitHub Action 🌎 |
This PR should be ready for review now. I have updated the description with the latest details and reasons behind the switch (in addition to what's already described in #1789). I'd love to hear opinions about how the macro to generate |
I found a way to relatively elegantly use enum to define routes without any major compromises. I have updated the PR with the new API and added a macro for it. At this point, some tests are missing and some fail. Also, the example doesn't compile right now. I'll be marking this PR as draft until those are fixed but this code should be ready to be reviewed. |
53adbee
to
6fcdfdc
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like all that's left is to fix the issues from CI.
Everything related to this PR should be good in CI now. |
Thanks a ton, @hamza1311! One thing that's still kind of lacking from this PR is the documentation. Specifically:
|
I'll create an issue for that (and also for some other features) |
How am I supposed to access BrowserRouter in regular |
@lausek Im going to guess u need history instead |
Description
This PR rewrites the
yew-router
crate.I'd appreciate any input about the API of the crate.
This API provided by this PR is a bit different and works as follows:
yew/packages/yew-router/tests/router.rs
Lines 12 to 67 in d25c077
A new
Routable
macro is introduced which generates the implementation forRoutable
trait.There will also be another (derive) macro which will be used to allow structs to be created from
Params
so query parameters are also not stringly typed. I've decided to keep query parameters separate as http-rs/route-recognizer#47 would provide a better and cleaner way to handle those. Right now, URLSearchParams is used for their parsing. A macro should be sufficient for now.So far, this PR:
Fixes #1245
Fixes #1101
Fixes #1679
Fixes #1102
Fixes #1107
Closes #1615 (the macro is removed)
Closes #1575 (the API is completely changed)
Closes #1096 (the API is completely changed)
Closes #1098 (the crate is removed entirely,
route_recognizer
is used instead)Closes #1261 (this implementation doesn't deal with state at all)
Closes #1585 (we no longer do the route parsing ourselves,
route_recognizer
is used instead. Maybe we could convert the route to something that is accepted byroute_recognizer
or patch it so it can accept different kinds of values)Checklist
cargo make pr-flow