Set up a subscription for the data provided by the data source.
()
| 370 | |
| 371 | /** Set up a subscription for the data provided by the data source. */ |
| 372 | private _subscribeToDataChanges() { |
| 373 | if (this._dataSubscription) { |
| 374 | return; |
| 375 | } |
| 376 | |
| 377 | let dataStream: Observable<readonly T[]> | undefined; |
| 378 | |
| 379 | if (isDataSource(this._dataSource)) { |
| 380 | dataStream = this._dataSource.connect(this); |
| 381 | } else if (isObservable(this._dataSource)) { |
| 382 | dataStream = this._dataSource; |
| 383 | } else if (Array.isArray(this._dataSource)) { |
| 384 | dataStream = observableOf(this._dataSource); |
| 385 | } |
| 386 | |
| 387 | if (!dataStream) { |
| 388 | if (typeof ngDevMode === 'undefined' || ngDevMode) { |
| 389 | throw getTreeNoValidDataSourceError(); |
| 390 | } |
| 391 | return; |
| 392 | } |
| 393 | |
| 394 | this._dataSubscription = this._getRenderData(dataStream) |
| 395 | .pipe(takeUntil(this._onDestroy)) |
| 396 | .subscribe(renderingData => { |
| 397 | this._renderDataChanges(renderingData); |
| 398 | }); |
| 399 | } |
| 400 | |
| 401 | /** Given an Observable containing a stream of the raw data, returns an Observable containing the RenderingData */ |
| 402 | private _getRenderData(dataStream: Observable<readonly T[]>): Observable<RenderingData<T>> { |
no test coverage detected