Public API for getting current routes from router
The use case: I want the ability to construct a dynamic breadcrumb based on the current route/state hierarchy.
The problem: There is currently no public API for accessing the chain of context on the router. The internal
currentHandlerInfos can be used, but not without feeling like you need to take a shower afterwards. This use case is common enough that users shouldn’t have to dig into the internal api.
Proposal: I propose we have a public API for accessing this information, but as I am not an API design expert, I am simply proposing the concept so those smarter than me can consider the issue. I’m happy to think up a variety of use cases if necessary, but the value is pretty apparent.
Some things to consider:
- The user should have access to the linear hierarchy of routes & contexts. i.e. router.get(‘currentRoutes’)
- Should they be able to query for a specific route to get just that set of handler/context data for convenience?
- What’s the data shape of each item in the array? Do we need all the keys found in
currentHandlerInfos, or can we simply have an array of the route (‘handler’) objects?