Skip to content

Instantly share code, notes, and snippets.

@ricmello
Last active May 25, 2018 03:40
Show Gist options
  • Save ricmello/06180cc05499b5acff99a4ed90de5ea2 to your computer and use it in GitHub Desktop.
Save ricmello/06180cc05499b5acff99a4ed90de5ea2 to your computer and use it in GitHub Desktop.
import { InjectionToken } from '@angular/core';
import { HttpClient, HttpEvent, HttpInterceptor, HttpHandler, HttpRequest } from '@angular/common/http';
import { Observable } from 'rxjs';
declare module '@angular/common/http/src/client' {
export interface HttpClient {
hideLoader(hide?: boolean): HttpClient;
}
}
class HttpInterceptorHandler implements HttpHandler {
constructor(private next: HttpHandler, private interceptor: HttpInterceptor) { }
handle(request: HttpRequest<any>): Observable<HttpEvent<any>> {
return this.interceptor.intercept(request, this.next);
}
}
export const HTTP_DYNAMIC_INTERCEPTORS = new InjectionToken<HttpInterceptor>('HTTP_DYNAMIC_INTERCEPTORS');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment