@anexia/registry-loading-interceptor
Version:
This library provides an interceptor which maps Http Requests to a Loading State.
31 lines (30 loc) • 1.39 kB
TypeScript
import { HttpEvent, HttpHandler, HttpInterceptor, HttpRequest } from '@angular/common/http';
import { Observable } from 'rxjs';
import { LoadingDictionary } from "../types/loading-dictionary";
import { RequestIdGeneratorStrategy } from "../interfaces/request-id-generator-strategy";
import { RequestFilterStrategy } from "../interfaces/request-filter-strategy";
export declare class RegistryLoadingInterceptor implements HttpInterceptor {
private readonly requestIdGenerator;
private readonly requestFilter;
/**
* registry exposing the loading state of watched http requests
*/
loadingState$: Observable<LoadingDictionary>;
/**
* monitors if any http request is loading by counting references.
*/
isAnyRequestLoading$: Observable<boolean>;
private readonly loadingDictionary;
private readonly stateChangeTrigger$;
private readonly networkRequestCounter$;
constructor(requestIdGenerator: RequestIdGeneratorStrategy, requestFilter: RequestFilterStrategy);
private static mapEventTypeToLoading;
intercept(request: HttpRequest<unknown>, delegate: HttpHandler): Observable<HttpEvent<unknown>>;
private mapHttpEventToLoadingState$;
private mapHttpEventToLoadingCount$;
private updateLoadingState;
private updateLoadingCounter;
private getRequestId;
private incrementCounter;
private decrementCounter;
}