Skip to content

Commit a01e8fa

Browse files
committed
feat(data-table): add disconnect to data source
1 parent 38b365c commit a01e8fa

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

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

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

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

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,7 @@ export class CdkTable<T> implements CollectionViewer {
179179
ngOnDestroy() {
180180
this._onDestroy.next();
181181
this._onDestroy.complete();
182+
this.dataSource.disconnect();
182183
}
183184

184185
ngOnInit() {
@@ -231,6 +232,8 @@ export class CdkTable<T> implements CollectionViewer {
231232
*/
232233
private _switchDataSource(dataSource: DataSource<T>) {
233234
this._data = [];
235+
236+
this.dataSource.disconnect();
234237
this._dataSource = dataSource;
235238

236239
if (this._isViewInitialized) {

0 commit comments

Comments
 (0)