The library is an angular interceptor service
To install the package run:
npm i @shumih/ng-http-events
provide service as Angular Interceptor in root module
@NgModule({
providers: [
{
provide: HTTP_INTERCEPTORS,
useExisting: HttpEventsService,
multi: true,
},
],
bootstrap: [AppComponent],
})
export class AppModule {}
and inject HttpEventsService wherever you want:
export class AppComponent {
public isWeatherRequestPending$ = this.httpEvents.getPending(HttpEventsService.urlEndsWith('/weather'));
public isCityInfoUpdateRequestPending$ = this.httpEvents.getPending(
req => req.method === 'PUT' && HttpEventsService.urlEndsWith('/city')(req)
);
constructor(private httpEvents: HttpEventsService) {}
}