-
-
Notifications
You must be signed in to change notification settings - Fork 7
URL Routing Support (SPA) #2
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
Comments
Examples have been added on potential styling patterns. There's a very high chance we pick the react style, but just want to make sure options are listed. |
I've updated this with a deep dive into what React-Router API endpoints need to be replicated for MVP URL routing support. |
I've done a little bit of thinking on this here and there and at the moment I'm leaning towards the idea of making this a separate package (e.g. |
If it can be a separate package then it should be. But need to consider whether the current infrastructure is flexible enough to support URL routing outside of core. |
Agreed. Especially given this is how react does it. With that said, without charges to core I'm not sure how clean the implementation will be. Regardless, I'm thinking I hack a prototype and see how bad it is before I go making changes in core before I really groc how routing works. |
I've created a draft implementation here: https://github.com/idom-team/idom-router I would discourage using it until I've had the time to flesh it out with more tests and documentation. The interface is subject to change (I haven't looked too closely at how React Router does things yet). I'm mostly interested in getting some early feedback on the implementation or for interface suggestions. For the moment though, usage looks like: from idom import component, html, run
from idom.backend import default
from idom_router.router import Route, Link, bind
Router = bind(default)
@component
def Sample():
return Router(
Route("/", Link({"id": "root"}, "to a", to="/a")),
Route("/a", Link({"id": "a"}, "to b", to="/b")),
Route("/b", Link({"id": "b"}, "to c", to="/c")),
Route("/c", Link({"id": "c"}, "to default", to="/default")),
Route("/*", html.h1({"id": "default"}, "Default")),
)
run(Sample) Route patterns follow standard glob rules (see Also, inside your routes, if you want to get the current location, you need to use |
I'm not entirely sure what you're trying to do with the third and fourth positional arguments ( I would rename |
This issue should be transferred to idom-team/idom-router |
Is this issue closable, since the initial package has been released? Or are we keeping it open to track the development goals? |
I think we can close this. Any features mentioned here that we should still implement can be created as separate issues. |
Should we have a quick discussion on which of the "Things to be implemented" on this issue are worth moving forward with? |
Current Situation
Currently, URL routes cannot be resolved.
Proposed Changes
Add support for URL routing.
Implementation Details
Create a
React-Router
equivalent.Here an example on how this can be implemented
And here's a reference video on explaining react-router.
Things to be implemented
BrowserRouter
Route
regex: bool = False
to allow for regex routes?Link
<a>
tag withprevent_default
pre-appliedregex: bool = False
to allow for regex linksuseHistory
useLocation
useParams
useMatch
Things that might not need to be implemented
Routes
(formerlySwitch
)matching more than one potential path.Routes
is used to force the router to only match one path.match_all
kwarg withinbrowser_router
NavLink
Redirect
MemoryRouter
StaticRouter
Prompt
The text was updated successfully, but these errors were encountered: