Skip to content

Commit dc9fe87

Browse files
committed
add collectionviewer to disconnect
1 parent 7ae1e97 commit dc9fe87

File tree

5 files changed

+11
-4
lines changed

5 files changed

+11
-4
lines changed

src/demo-app/data-table/person-data-source.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export class PersonDataSource extends DataSource<any> {
1313

1414
connect(): Observable<UserData[]> {
1515
const displayDataChanges = [
16-
this._paginator.page,
16+
this._paginator.page,
1717
this._sort.mdSortChange,
1818
this._peopleDatabase.dataChange
1919
];
@@ -26,6 +26,10 @@ export class PersonDataSource extends DataSource<any> {
2626
});
2727
}
2828

29+
disconnect() {
30+
// No-op
31+
}
32+
2933
/** Returns a sorted copy of the database data. */
3034
getSortedData(): UserData[] {
3135
const data = this._peopleDatabase.data.slice();

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,5 @@ export interface CollectionViewer {
1414

1515
export abstract class DataSource<T> {
1616
abstract connect(collectionViewer: CollectionViewer): Observable<T[]>;
17-
disconnect() {}
17+
abstract disconnect(collectionViewer: CollectionViewer): void;
1818
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ export class CdkTable<T> implements CollectionViewer {
185185
this._onDestroy.next();
186186
this._onDestroy.complete();
187187
if (this.dataSource) {
188-
this.dataSource.disconnect();
188+
this.dataSource.disconnect(this);
189189
}
190190
}
191191

@@ -242,7 +242,7 @@ export class CdkTable<T> implements CollectionViewer {
242242
this._data = [];
243243

244244
if (this._dataSource) {
245-
this.dataSource.disconnect();
245+
this.dataSource.disconnect(this);
246246
}
247247
this._dataSource = dataSource;
248248

src/lib/sort/sort.spec.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,7 @@ class FakeDataSource extends DataSource<any> {
203203
connect(collectionViewer: CollectionViewer): Observable<any[]> {
204204
return map.call(collectionViewer.viewChange, () => []);
205205
}
206+
disconnect() {}
206207
}
207208

208209
@Component({

src/lib/table/table.spec.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@ class FakeDataSource extends DataSource<TestData> {
6868
return this._dataChange;
6969
}
7070

71+
disconnect() {}
72+
7173
addData() {
7274
const nextIndex = this.data.length + 1;
7375

0 commit comments

Comments
 (0)