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

Method _switchDataSource

src/cdk/tree/tree.ts:344–361  ·  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 node outlet. Otherwise start listening for new data.

(dataSource: DataSource<T> | Observable<T[]> | T[])

Source from the content-addressed store, hash-verified

342 * clearing the node outlet. Otherwise start listening for new data.
343 */
344 private _switchDataSource(dataSource: DataSource<T> | Observable<T[]> | T[]) {
345 if (this._dataSource && typeof (this._dataSource as DataSource<T>).disconnect === 'function') {
346 (this.dataSource as DataSource<T>).disconnect(this);
347 }
348
349 this._dataSubscription?.unsubscribe();
350 this._dataSubscription = undefined;
351
352 // Remove the all dataNodes if there is now no data source
353 if (!dataSource) {
354 this._nodeOutlet.viewContainer.clear();
355 }
356
357 this._dataSource = dataSource;
358 if (this._nodeDefs) {
359 this._subscribeToDataChanges();
360 }
361 }
362
363 _getExpansionModel() {
364 if (!this.treeControl) {

Callers 1

dataSourceMethod · 0.95

Calls 3

clearMethod · 0.65
disconnectMethod · 0.45

Tested by

no test coverage detected