Auxilary routes half working
Closed this issue · 1 comments
I was trying to use the lib in our app where a component can tell the platform to browse to an auxiliary route. This works without issue, but the problem is that when that auxiliary route changes in the platform the component is not notified through the areRouting directive since it subscribes to route.url in route.url is only updated for the router-outlet it is within.
For my purposes I changed the routing.directive ngOnInit from
this.route.url
.pipe(
map(() => this.router.url),
takeUntil(this.destroyed$)
)
.subscribe((url) => (this.element.nativeElement.route = url));
to
this.router.events
.pipe(
filter((e) => e instanceof NavigationEnd),
map(() => this.router.url),
takeUntil(this.destroyed$)
)
.subscribe((url) => (this.element.nativeElement.route = url));
This catches all route changes covered by all auxiliary routes so the component can get notified of any changes and do what it needs to do.
I just wanted to run that by you to see if that would be a sensible change for a PR back to the lib or does it have some unintended consequences?
Hi @rsouthgate! Thanks for reporting and the detailed explanation! The different implementation looks reasonable to me, the only behaviour changes I could imagine would be about the initial url that might be missing if no navigation has happened yet and navigations that have been interrupted due to guards. I can verify and test after my vacation. Happy to accept a PR for that change if you'd like to contribute it.