Skip to content

Commit 365ed7c

Browse files
committed
Revert "docs(material/table): use declarative idiomatic RxJS in table-http-example (#22053)" (#22725)
This reverts commit 67dc1fd. (cherry picked from commit 9295ce5)
1 parent 54e832d commit 365ed7c

File tree

4 files changed

+9
-11
lines changed

4 files changed

+9
-11
lines changed

scripts/shim-scss-imports.js

100644100755
File mode changed.

src/components-examples/material/table/table-http/table-http-example.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
.example-table-container {
88
position: relative;
9-
height: 400px;
9+
max-height: 400px;
1010
overflow: auto;
1111
}
1212

src/components-examples/material/table/table-http/table-http-example.html

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,8 @@
99

1010
<div class="example-table-container">
1111

12-
<table mat-table [dataSource]="filteredAndPagedIssues" class="example-table" matSort
13-
matSortActive="created" matSortDisableClear matSortDirection="desc"
14-
(matSortChange)="resetPaging()">
12+
<table mat-table [dataSource]="data" class="example-table"
13+
matSort matSortActive="created" matSortDisableClear matSortDirection="desc">
1514
<!-- Number Column -->
1615
<ng-container matColumnDef="number">
1716
<th mat-header-cell *matHeaderCellDef>#</th>

src/components-examples/material/table/table-http/table-http-example.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import {catchError, map, startWith, switchMap} from 'rxjs/operators';
1616
export class TableHttpExample implements AfterViewInit {
1717
displayedColumns: string[] = ['created', 'state', 'number', 'title'];
1818
exampleDatabase: ExampleHttpDatabase | null;
19-
filteredAndPagedIssues: Observable<GithubIssue[]>;
19+
data: GithubIssue[] = [];
2020

2121
resultsLength = 0;
2222
isLoadingResults = true;
@@ -30,7 +30,10 @@ export class TableHttpExample implements AfterViewInit {
3030
ngAfterViewInit() {
3131
this.exampleDatabase = new ExampleHttpDatabase(this._httpClient);
3232

33-
this.filteredAndPagedIssues = merge(this.sort.sortChange, this.paginator.page)
33+
// If the user changes the sort order, reset back to the first page.
34+
this.sort.sortChange.subscribe(() => this.paginator.pageIndex = 0);
35+
36+
merge(this.sort.sortChange, this.paginator.page)
3437
.pipe(
3538
startWith({}),
3639
switchMap(() => {
@@ -52,11 +55,7 @@ export class TableHttpExample implements AfterViewInit {
5255
this.isRateLimitReached = true;
5356
return observableOf([]);
5457
})
55-
);
56-
}
57-
58-
resetPaging(): void {
59-
this.paginator.pageIndex = 0;
58+
).subscribe(data => this.data = data);
6059
}
6160
}
6261

0 commit comments

Comments
 (0)