Skip to content

Commit 6bc1b9f

Browse files
committed
Use RxJS 5.5 lettable operators
1 parent a92d92f commit 6bc1b9f

File tree

3 files changed

+14
-12
lines changed

3 files changed

+14
-12
lines changed

CHANGELOG.MD

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ See [customization](https://github.com/mpalourdio/ng-http-loader#customizing-the
88

99
The library footprint has been reduced by minifying templates and stylesheets before inlining them.
1010

11+
The library now takes advantage of [RxJS lettable operators](https://github.com/ReactiveX/rxjs/blob/master/doc/lettable-operators.md)
12+
1113
## v0.5.1
1214

1315
This release fixes a bug that could cause the spinner to not show if an http request were performed **before** the spinner component was initialized.

src/components/spinner/spinner.component.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import { Spinkit } from '../../spinkits';
1313
import { PendingInterceptorService } from '../../services/pending-interceptor.service';
1414
import { timer } from 'rxjs/observable/timer';
1515
import { Observable } from 'rxjs/Observable';
16-
import 'rxjs/add/operator/debounce';
16+
import { debounce } from 'rxjs/operators';
1717

1818
@Component({
1919
selector: 'spinner',
@@ -37,7 +37,7 @@ export class SpinnerComponent implements OnDestroy, OnInit {
3737
constructor(private pendingRequestInterceptorService: PendingInterceptorService) {
3838
this.subscription = this.pendingRequestInterceptorService
3939
.pendingRequestsStatus
40-
.debounce(this.handleDebounce.bind(this))
40+
.pipe(debounce(this.handleDebounce.bind(this)))
4141
.subscribe(hasPendingRequests => {
4242
this.isSpinnerVisible = hasPendingRequests;
4343
});

src/services/pending-interceptor.service.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,7 @@ import { Injectable } from '@angular/core';
1111
import { HttpEvent, HttpHandler, HttpInterceptor, HttpRequest } from '@angular/common/http';
1212
import { Observable } from 'rxjs/Observable';
1313
import { ReplaySubject } from 'rxjs/ReplaySubject';
14-
import 'rxjs/add/operator/map';
15-
import 'rxjs/add/operator/catch';
16-
import 'rxjs/add/operator/finally';
14+
import { catchError, finalize, map } from 'rxjs/operators';
1715
import 'rxjs/add/observable/throw';
1816

1917
@Injectable()
@@ -51,21 +49,23 @@ export class PendingInterceptorService implements HttpInterceptor {
5149
}
5250
}
5351

54-
return next.handle(req).map(event => {
55-
return event;
56-
})
57-
.catch(error => {
52+
return next.handle(req).pipe(
53+
map(event => {
54+
return event;
55+
}),
56+
catchError(error => {
5857
return Observable.throw(error);
59-
})
60-
.finally(() => {
58+
}),
59+
finalize(() => {
6160
if (!shouldBypass) {
6261
this._pendingRequests--;
6362

6463
if (0 === this._pendingRequests) {
6564
this._pendingRequestsStatus.next(false);
6665
}
6766
}
68-
});
67+
})
68+
);
6969
}
7070
}
7171

0 commit comments

Comments
 (0)