@@ -2,12 +2,12 @@ import {Component, AfterViewInit, ViewChild} from '@angular/core';
22import { HttpClient } from '@angular/common/http' ;
33import { MatPaginator , MatSort , MatTableDataSource } from '@angular/material' ;
44import { Observable } from 'rxjs/Observable' ;
5- import 'rxjs/add /observable/merge' ;
6- import 'rxjs/add /observable/of' ;
7- import 'rxjs/add/operator/catch ' ;
8- import 'rxjs/add/operator /map' ;
9- import 'rxjs/add/operator /startWith' ;
10- import 'rxjs/add/operator /switchMap' ;
5+ import { merge } from 'rxjs/observable/merge' ;
6+ import { of } from 'rxjs/observable/of' ;
7+ import { catchError } from 'rxjs/operators/catchError ' ;
8+ import { map } from 'rxjs/operators /map' ;
9+ import { startWith } from 'rxjs/operators /startWith' ;
10+ import { switchMap } from 'rxjs/operators /switchMap' ;
1111
1212/**
1313 * @title Table retrieving data through HTTP
@@ -37,28 +37,29 @@ export class TableHttpExample implements AfterViewInit {
3737 // If the user changes the sort order, reset back to the first page.
3838 this . sort . sortChange . subscribe ( ( ) => this . paginator . pageIndex = 0 ) ;
3939
40- Observable . merge ( this . sort . sortChange , this . paginator . page )
41- . startWith ( null )
42- . switchMap ( ( ) => {
40+ merge ( this . sort . sortChange , this . paginator . page )
41+ . pipe (
42+ startWith ( { } ) ,
43+ switchMap ( ( ) => {
4344 this . isLoadingResults = true ;
4445 return this . exampleDatabase ! . getRepoIssues (
45- this . sort . active , this . sort . direction , this . paginator . pageIndex ) ;
46- } )
47- . map ( data => {
46+ this . sort . active , this . sort . direction , this . paginator . pageIndex ) ;
47+ } ) ,
48+ map ( data => {
4849 // Flip flag to show that loading has finished.
4950 this . isLoadingResults = false ;
5051 this . isRateLimitReached = false ;
5152 this . resultsLength = data . total_count ;
5253
5354 return data . items ;
54- } )
55- . catch ( ( ) => {
55+ } ) ,
56+ catchError ( ( ) => {
5657 this . isLoadingResults = false ;
5758 // Catch if the GitHub API has reached its rate limit. Return empty data.
58- this . isRateLimitReached = true ;
59- return Observable . of ( [ ] ) ;
59+ // this.isRateLimitReached = true;
60+ return of ( [ ] ) ;
6061 } )
61- . subscribe ( data => this . dataSource . data = data ) ;
62+ ) . subscribe ( data => this . dataSource . data = data ) ;
6263 }
6364}
6465
0 commit comments