* 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[])
| 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) { |
no test coverage detected