Skip to content

Commit df381ac

Browse files
committed
chore(table): update table data source in prep for rxjs6
1 parent a49f396 commit df381ac

File tree

1 file changed

+12
-13
lines changed

1 file changed

+12
-13
lines changed

src/lib/table/table-data-source.ts

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ import {MatPaginator, PageEvent} from '@angular/material/paginator';
1212
import {MatSort, Sort} from '@angular/material/sort';
1313
import {Observable} from 'rxjs/Observable';
1414
import {Subscription} from 'rxjs/Subscription';
15-
import {combineLatest} from 'rxjs/operators/combineLatest';
1615
import {map} from 'rxjs/operators/map';
1716
import {startWith} from 'rxjs/operators/startWith';
17+
import {combineLatest} from 'rxjs/observable/combineLatest';
1818
import {empty} from 'rxjs/observable/empty';
1919
import {_isNumberValue} from '@angular/cdk/coercion';
2020

@@ -186,19 +186,18 @@ export class MatTableDataSource<T> extends DataSource<T> {
186186
this._renderChangesSubscription.unsubscribe();
187187
}
188188

189+
const dataStream = this._data;
189190
// Watch for base data or filter changes to provide a filtered set of data.
190-
this._renderChangesSubscription = this._data.pipe(
191-
combineLatest(this._filter),
192-
map(([data]) => this._filterData(data)),
193-
// Watch for filtered data or sort changes to provide an ordered set of data.
194-
combineLatest(sortChange.pipe(startWith(null!))),
195-
map(([data]) => this._orderData(data)),
196-
// Watch for ordered data or page changes to provide a paged set of data.
197-
combineLatest(pageChange.pipe(startWith(null!))),
198-
map(([data]) => this._pageData(data))
199-
)
191+
const filteredData = combineLatest(dataStream, this._filter)
192+
.pipe(map(([data]) => this._filterData(data)));
193+
// Watch for filtered data or sort changes to provide an ordered set of data.
194+
const orderedData = combineLatest(filteredData, sortChange.pipe(startWith(null!)))
195+
.pipe(map(([data]) => this._orderData(data)));
196+
// Watch for ordered data or page changes to provide a paged set of data.
197+
const paginatedData = combineLatest(orderedData, pageChange.pipe(startWith(null!)))
198+
.pipe(map(([data]) => this._pageData(data)));
200199
// Watched for paged data changes and send the result to the table to render.
201-
.subscribe(data => this._renderData.next(data));
200+
paginatedData.subscribe(data => this._renderData.next(data));
202201
}
203202

204203
/**
@@ -271,4 +270,4 @@ export class MatTableDataSource<T> extends DataSource<T> {
271270
* @docs-private
272271
*/
273272
disconnect() { }
274-
}
273+
}

0 commit comments

Comments
 (0)