Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upUrlMatcher as a service #17145
UrlMatcher as a service #17145
Comments
|
Hi all! Have any news about this brilliant feature? |
|
Would be absolutely amazing if we could have this! |
|
Also, it would be nice to have an ability to return |
|
@korenb why |
|
@Dok11 , you're right! it should support Observable. Because sometimes i need to call api before the matcher has resolved |
|
I agree! If the matchUrl function could support asynchronous behaviour, would be really good |
|
@korenb, do you have a workaround for the case when you need to call API before the matcher has resolved? |
|
and +1 for the feature, would be very useful |
|
@EddyP23 In short, the route which needs an asynchronous matcher would need to be preceded by a route that doesn't, and that initial route would need to get the remote information via a resolver or a service injected into a component. If your workflow doesn't give you the opportunity to preload the data, you could have a route that presents a loading screen with a distinct URL, do the async request, and redirect to the route with the async matcher. |
|
It's been a year since last comment and I would love to have this feature on my application. |
|
I also need this feature badly. It'd be much easier to inject other services into this than grabbing Injector instance from main.ts. Plus, asynchronous path matching is a necessity. Unfortunately, matcher doesn't take async functions. Example Use Case: A URL segment can represent a tweet, user, group and I want to lazily load a module only after finding out what this segment is post API call. |
|
Why not |
|
Our particular use case is that we load a different module and component for the same route depending on the user's type.
|
|
I thought I could do a lazy match of slugs based on a service where I fetch observables from... but apparently not, because
In a framework driven by observables and dependency injection, finding something that suddenly doesn't have either is a real downer. To find an ancient, well-upovted issue without a single official comment by a team members is an even bigger downer. It's been two and a half years... |
|
That would be perfect, so matcher can be used just as guards or resolvers. Additionally it looks that matcher and resolver can be at the same time, not specified in the documentation, the resolver is ignored. Retrieve information or 'resolve' is a responsibility of the resolver, instead that the matcher return a paramMap would be good if it is used as a :parameter which at the end, a matcher is used when a :parameter is not enough, then matcher -> guard/resolver -> component. |
|
Struggling with this for quite a while, I wonder if this can be partially solved by the Injecting the router service in the router module and then conditionally add the route configurations... Edit: It does reset all routes created, so using that approach inside of a child router module breaks all router modules. |
I'm submitting a ... (check one with "x")
Current behavior
Only a function can be set as the
urlMatcherof a route.Expected behavior
A DI-resolved service or function can be set as the
urlMatcherallowing for further injection. I'd expect this to work in an identical way to how the resolver properties can either be services that implement theResolve<T>interface OR can be an inlineresolve()function.Minimal reproduction of the problem with instructions
N/A
What is the motivation / use case for changing the behavior?
My use case is that
InterruptComponentshould resolve if some system state (managed by a service) is currently true. If not, I want to skip this route an let other routes attempt matching. In my case I want to greedily consume the entire sub-path and display a specific component, but only in certain circumstances.Please tell us about your environment:
N/A