I'm adding an Angular 8 route resolver to prefetch data. Upon failure (for any reason) I return an EMPTY to cancel the route navigation. However, when I test this, I can step into the catchError block, it shows the toaster, and it returns EMPTY, but the route navigation is not being canceled. According to all the articles I have read, this should work. Wanted to know if anybody sees something that I don't. I have only included the resolve method, since all other configuration is working.
resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<Country[]> | Observable<never> {
return this.countryService.getCountries().pipe(
mergeMap((countries) => {
if (countries)
{
return of(countries);
}
return EMPTY;
}),
catchError(error => {
this.toasterService.pop('error', '', 'There was a problem prefetching the data required to submit a request. If the problem persists, please notify the administrator.');
return EMPTY;
}));
}
I expect this code to cancel navigation, per angular documentation.