Comments (8)
Thanks for the suggested solution approaches!
Just to share my experience: I bumped into the /users
vs. /users/:name
issue within 10 min after prototyping carbon-route
into our application. Although the suggested solutions are all reasonable, I found it a quite demotivating hurdle for adoption the routing elements, considering that the use case feels pretty common.
from app-route.
This seems like something that could fall under the umbrella of "solved by inheritance." For example, a user could implement a carbon-route
derivative that has stricter matching semantics.
from app-route.
Maybe...I tried to dive in and build a simple app structure (the Polymer Starter Kit routes) using carbon-route
and I was pretty quickly stymied as to how to differentiate between /users
and /users/:name
in a simple and declarative fashion.
Might be missing an obvious way to make that work well -- how would you approach it?
from app-route.
We spent very little time designing matching semantics for carbon-route
. This was excusable because inheritance can allow us to offer a derived element with better semantics.
That said, in your case you can bind to the active
property on the route that matches /users/:name
and use that to achieve the differentiation you are looking for. For example, when the route goes from /users/foo
to /users
, the active
property on the carbon-route
that matches /users/:name
will change to false
.
from app-route.
Fair enough. If you think inheritance is a better way to go about this, please feel free to close.
from app-route.
@rictic what are your thoughts on this?
from app-route.
IMO we do want the matching syntax to be reasonably flexible by 1.0, especially if it's a common problem (like this is), and the next best alternative isn't great (which I'm not yet totally sold on for this case).
I was chatting in the slack channel with @TimvdLippe who's also been looking into integrating carbon-route and PSK. The solution we went with was that the main page should could be updated to use iron-pages
to select between the home
, contact
, and users
pages. The users
page would be handled by a custom element that would have further routing inside of itself to differentiate between displaying all users vs a specific user.
I like this because it encourages building modular elements. If it's still awkward with that use case then I think the case is stronger that we should implement a match-end-of-route feature in pattern
.
My perspective in a tl;dr: this seems reasonable, but we want to keep the base carbon-route super small and simple, so we'd like to hear more use cases. No matter what we do for pattern
syntax and capabilities, we expect others to extend carbon-route with their own matching logic.
from app-route.
The solution we went with was that the main page should could be updated to use iron-pages to select between the home, contact, and users pages. The users page would be handled by a custom element that would have further routing inside of itself to differentiate between displaying all users vs a specific user.
I like this because it encourages building modular elements. If it's still awkward with that use case then I think the case is stronger that we should implement a match-end-of-route feature in pattern.
@rictic - Encouraging modular elements is definitely a good point. But would sub routing work also with neon-animated-pages
which, to my knowledge, require to have all pages on the same level?
from app-route.
Related Issues (20)
- Observer set on `routeData` keeps firing in the background after navigating to a different page/element. HOT 3
- Changing data.page doesn't update history HOT 5
- Probleme with app-route conprehension HOT 1
- Exception Cannot create property '__queryParams' on string '}' when using 2 app-route with pattern that don't matching HOT 1
- Property "data" doesn't change when the route isn't active HOT 4
- Suggestion: Deprecate in favor of a library like Platinum Service Worker HOT 4
- app-location.html, app-router-converter-behavior.html, app-route-converter.html etc files are missing after bower install HOT 5
- queryParams blank when using client-side navigation
- Any way to override iron-location's dwellTime? HOT 3
- P1 bug: Missing import on"3.0.0-pre.6" app-route HOT 2
- Url can't change
- Correcting bad syntax context in hashes vs paths section HOT 1
- gcnfkg,j
- Error when using `auto-activate` when routing from activated path to rootPath HOT 1
- Running into an import problem with Polymer 3 HOT 16
- Error when using use-hash-as-path
- Outdated docs links
- Links to Online Docs and Demos missing
- Question - App Route with Sub Paging.
- `route-changed` fired twice with bad state HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from app-route.