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