I am in the process of building a web application with Angular 6.
One key aspect of this project is implementing an interceptor service that utilizes the interface HttpInterceptor
to intercept specific types of HTTP requests.
So far, the interceptor class is functioning flawlessly and successfully capturing the intended HTTP calls.
Given that there are various graphical components within the application, I am curious about the best approach for displaying a graphic component (e.g. spinner or modal window) by utilizing code from the interceptor.
Let's consider an example:
@Injectable()
export class MyHttpInterceptor implements HttpInterceptor {
intercept(req: HttpRequest<any>, next: HttpHandler ) {
let updateReq;
updateReq = req.clone({
setParams: {
responseType: 'no-type'
}
});
console.log(updateReq);
return next.handle(updateReq).pipe(tap(
event => console.log(event),
err => console.log(err)
));
}
}
For instance, if I wanted to check for certain properties within req
and then display a graphical component accordingly, how would I go about implementing this across my entire application?