MCPcopy Index your code
hub / github.com/angular/components / _switchDataSource

Method _switchDataSource

src/cdk/table/table.ts:1202–1225  ·  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

1200 * clearing the row outlet. Otherwise start listening for new data.
1201 */
1202 private _switchDataSource(dataSource: CdkTableDataSourceInput<T>) {
1203 this._data = [];
1204
1205 if (isDataSource(this.dataSource)) {
1206 this.dataSource.disconnect(this);
1207 }
1208
1209 // Stop listening for data from the previous data source.
1210 if (this._renderChangeSubscription) {
1211 this._renderChangeSubscription.unsubscribe();
1212 this._renderChangeSubscription = null;
1213 }
1214
1215 if (!dataSource) {
1216 if (this._dataDiffer) {
1217 this._dataDiffer.diff([]);
1218 }
1219 if (this._rowOutlet) {
1220 this._rowOutlet.viewContainer.clear();
1221 }
1222 }
1223
1224 this._dataSource = dataSource;
1225 }
1226
1227 /** Set up a subscription for the data provided by the data source. */
1228 private _observeRenderChanges() {

Callers 1

dataSourceMethod · 0.95

Calls 3

isDataSourceFunction · 0.90
clearMethod · 0.65
disconnectMethod · 0.45

Tested by

no test coverage detected