|
9 | 9 |
|
10 | 10 | import { Component, Input, OnDestroy, OnInit } from '@angular/core'; |
11 | 11 | import { BehaviorSubject, merge, Observable, Subscription, timer } from 'rxjs'; |
12 | | -import { debounce, distinctUntilChanged, partition, switchMap } from 'rxjs/operators'; |
| 12 | +import { debounce, distinctUntilChanged, partition, switchMap, tap } from 'rxjs/operators'; |
13 | 13 | import { PendingInterceptorService } from '../services/pending-interceptor.service'; |
14 | 14 | import { SpinnerVisibilityService } from '../services/spinner-visibility.service'; |
15 | 15 | import { Spinkit } from '../spinkits'; |
@@ -56,8 +56,11 @@ export class NgHttpLoaderComponent implements OnDestroy, OnInit { |
56 | 56 | ), |
57 | 57 | this.spinnerVisibilityService.visibility$, |
58 | 58 | ) |
59 | | - .pipe(distinctUntilChanged()) |
60 | | - .subscribe(h => this.handleSpinnerVisibility(h)); |
| 59 | + .pipe( |
| 60 | + distinctUntilChanged(), |
| 61 | + tap(h => this.updateVisibilityDuration(h)) |
| 62 | + ) |
| 63 | + .subscribe(h => this._isSpinnerVisible$.next(h)); |
61 | 64 | } |
62 | 65 |
|
63 | 66 | ngOnInit(): void { |
@@ -111,11 +114,10 @@ export class NgHttpLoaderComponent implements OnDestroy, OnInit { |
111 | 114 | this.pendingInterceptorService.filteredHeaders = this.filteredHeaders; |
112 | 115 | } |
113 | 116 |
|
114 | | - private handleSpinnerVisibility(showSpinner: boolean): void { |
| 117 | + private updateVisibilityDuration(showSpinner: boolean): void { |
115 | 118 | if (showSpinner) { |
116 | 119 | this.visibleUntil = Date.now() + this.minDuration; |
117 | 120 | } |
118 | | - this._isSpinnerVisible$.next(showSpinner); |
119 | 121 | } |
120 | 122 |
|
121 | 123 | private getVisibilityTimer$(): Observable<number> { |
|
0 commit comments