@ngx-loading-bar/http-client
Version:
Automatic page loading / progress bar for Angular
1 lines • 3.04 kB
Source Map (JSON)
{"version":3,"file":"ngx-loading-bar-http-client.js","sources":["ng://@ngx-loading-bar/http-client/loading-bar.interceptor.ts","ng://@ngx-loading-bar/http-client/http.module.ts","ng://@ngx-loading-bar/http-client/ngx-loading-bar-http-client.ts"],"sourcesContent":["import { LoadingBarService } from '@ngx-loading-bar/core';\nimport { Injectable } from '@angular/core';\nimport { HttpEvent, HttpInterceptor, HttpHandler, HttpRequest } from '@angular/common/http';\nimport { Observable } from 'rxjs';\nimport { finalize, tap } from 'rxjs/operators';\n\n@Injectable()\nexport class LoadingBarInterceptor implements HttpInterceptor {\n constructor(private loader: LoadingBarService) {}\n\n intercept(req: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {\n // https://github.com/angular/angular/issues/18155\n if (req.headers.has('ignoreLoadingBar')) {\n return next.handle(req.clone({ headers: req.headers.delete('ignoreLoadingBar') }));\n }\n\n let started = false;\n const ref = this.loader.useRef('http');\n return next.handle(req).pipe(\n tap(() => {\n if (!started) {\n ref.start();\n started = true;\n }\n }),\n finalize(() => started && ref.complete()),\n );\n }\n}\n","import { LoadingBarModule, LoadingBarService } from '@ngx-loading-bar/core';\nimport { NgModule } from '@angular/core';\nimport { HttpClientModule, HTTP_INTERCEPTORS } from '@angular/common/http';\nimport { LoadingBarInterceptor } from './loading-bar.interceptor';\n\n@NgModule({\n imports: [HttpClientModule, LoadingBarModule],\n exports: [HttpClientModule, LoadingBarModule],\n providers: [\n {\n provide: HTTP_INTERCEPTORS,\n useClass: LoadingBarInterceptor,\n multi: true,\n },\n ],\n})\nexport class LoadingBarHttpClientModule {}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public_api';\n\nexport {LoadingBarInterceptor as ɵa} from './loading-bar.interceptor';"],"names":[],"mappings":";;;;;;;IAQE,+BAAoB,MAAyB;QAAzB,WAAM,GAAN,MAAM,CAAmB;KAAI;IAEjD,yCAA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