Set up a subscription for the data provided by the data source.
()
| 1226 | |
| 1227 | /** Set up a subscription for the data provided by the data source. */ |
| 1228 | private _observeRenderChanges() { |
| 1229 | // If no data source has been set, there is nothing to observe for changes. |
| 1230 | if (!this.dataSource) { |
| 1231 | return; |
| 1232 | } |
| 1233 | |
| 1234 | let dataStream: Observable<readonly T[]> | undefined; |
| 1235 | |
| 1236 | if (isDataSource(this.dataSource)) { |
| 1237 | dataStream = this.dataSource.connect(this); |
| 1238 | } else if (isObservable(this.dataSource)) { |
| 1239 | dataStream = this.dataSource; |
| 1240 | } else if (Array.isArray(this.dataSource)) { |
| 1241 | dataStream = observableOf(this.dataSource); |
| 1242 | } |
| 1243 | |
| 1244 | if (dataStream === undefined && (typeof ngDevMode === 'undefined' || ngDevMode)) { |
| 1245 | throw getTableUnknownDataSourceError(); |
| 1246 | } |
| 1247 | |
| 1248 | this._renderChangeSubscription = combineLatest([dataStream!, this.viewChange]) |
| 1249 | .pipe(takeUntil(this._onDestroy)) |
| 1250 | .subscribe(([data, range]) => { |
| 1251 | this._data = data || []; |
| 1252 | this._renderedRange = range; |
| 1253 | this._dataStream.next(data); |
| 1254 | this.renderRows(); |
| 1255 | }); |
| 1256 | } |
| 1257 | |
| 1258 | /** |
| 1259 | * Clears any existing content in the header row outlet and creates a new embedded view |
no test coverage detected