26 lines
925 B
TypeScript
26 lines
925 B
TypeScript
import { HttpEvent, HttpHandler, HttpRequest } from '@angular/common/http';
|
|
import { Injectable } from '@angular/core';
|
|
import { Observable } from 'rxjs';
|
|
import { finalize } from 'rxjs/operators';
|
|
import { ProgressIndicationService } from '../../../core/services/progress-indication/progress-indication-service';
|
|
import { BaseInterceptor } from './base.interceptor';
|
|
import { InterceptorType } from './interceptor-type';
|
|
|
|
@Injectable()
|
|
export class ProgressIndicationInterceptor extends BaseInterceptor {
|
|
|
|
constructor(
|
|
private progressIndicationService: ProgressIndicationService) { super(); }
|
|
|
|
get type(): InterceptorType { return InterceptorType.ProgressIndication; }
|
|
|
|
interceptRequest(req: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {
|
|
this.progressIndicationService.show();
|
|
return next
|
|
.handle(req).pipe(
|
|
finalize(() => {
|
|
this.progressIndicationService.dismiss();
|
|
}));
|
|
}
|
|
}
|