MCPcopy Create free account
hub / github.com/angular/components / _switchDataSource

Method _switchDataSource

src/cdk/table/table.ts:1220–1243  ·  view source on GitHub ↗

* Switch to the provided data source by resetting the data and unsubscribing from the current * render change subscription if one exists. If the data source is null, interpret this by * clearing the row outlet. Otherwise start listening for new data.

(dataSource: CdkTableDataSourceInput<T>)

Source from the content-addressed store, hash-verified

1218 * clearing the row outlet. Otherwise start listening for new data.
1219 */
1220 private _switchDataSource(dataSource: CdkTableDataSourceInput<T>) {
1221 this._data = [];
1222
1223 if (isDataSource(this.dataSource)) {
1224 this.dataSource.disconnect(this);
1225 }
1226
1227 // Stop listening for data from the previous data source.
1228 if (this._renderChangeSubscription) {
1229 this._renderChangeSubscription.unsubscribe();
1230 this._renderChangeSubscription = null;
1231 }
1232
1233 if (!dataSource) {
1234 if (this._dataDiffer) {
1235 this._dataDiffer.diff([]);
1236 }
1237 if (this._rowOutlet) {
1238 this._rowOutlet.viewContainer.clear();
1239 }
1240 }
1241
1242 this._dataSource = dataSource;
1243 }
1244
1245 /** Set up a subscription for the data provided by the data source. */
1246 private _observeRenderChanges() {

Callers 1

dataSourceMethod · 0.95

Calls 3

isDataSourceFunction · 0.90
clearMethod · 0.65
disconnectMethod · 0.45

Tested by

no test coverage detected