I have the following Route Config:
{
path: ':id',
component: MyComponent,
resolve: {
data: MyResolver
}
}
The Resolver will simply do an HTTP call to fetch some data:
resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<Artist> {
return this.service.getData(route.params.id);
}
The Component contains some tabs and has some functionality to set / change matrix params accordingly.
- When first visiting the route, the URL will be
http://.../#/123
- When the user clicks a tab, it will change to
http://.../#/123;tab=foo
When the user now manually changes the URL the Resolver will run again. This is okay when he changes the :id
. But it shouldn't happen when he only changes the tab
param.
Any idea how to do this?
I thought about adding some distinctUntilChanged
into the resolver, but I couldn't get it working. Something like:
return of(route.params.id).pipe(
distinctUntilChanged(),
switchMap(val => this.service.getData(val)
)
But maybe I just did it wrong.