My Angular application contains the following HTTP interceptor:
import { Observable } from 'rxjs';
import { Injectable } from '@angular/core';
import { HttpInterceptor, HttpResponse } from '@angular/common/http';
import { HttpRequest } from '@angular/common/http';
import { HttpHandler } from '@angular/common/http';
import { HttpEvent } from '@angular/common/http';
import { tap } from 'rxjs/operators';
import { SpinnerService } from '../sharedServices/spinner.service';
@Injectable()
export class CustomHttpInterceptor implements HttpInterceptor {
constructor(private spinnerService: SpinnerService) { }
intercept(req: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {
this.spinnerService.show();
return next.handle(req)
.pipe(tap((event: HttpEvent<any>) => {
if (event instanceof HttpResponse) {
this.spinnerService.hide();
}
}, (error) => {
this.spinnerService.hide();
}));
}
}
Within my code, I have utilized the tap method.
I am encountering a warning that suggests using an observer argument instead of separate callback arguments. The signatures with separate callbacks will be removed in V8.
While the current implementation is functioning correctly, there is a strike mark displayed on the usage of the tap keyword alongside the aforementioned warning message.