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

Method _subscribeToDataChanges

src/cdk/tree/tree.ts:372–399  ·  view source on GitHub ↗

Set up a subscription for the data provided by the data source.

()

Source from the content-addressed store, hash-verified

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>> {

Callers 2

ngAfterContentCheckedMethod · 0.95
_switchDataSourceMethod · 0.95

Calls 5

_getRenderDataMethod · 0.95
_renderDataChangesMethod · 0.95
isDataSourceFunction · 0.90
connectMethod · 0.45

Tested by

no test coverage detected