license import { CollectionViewer , DataSource } from '@angular/cdk/collections' ; import { BehaviorSubject , merge , Observable } from 'rxjs' ; import { map } from 'rxjs/operators' ; /**
 * Data source for nested tree.
 *
 * The data source for nested tree doesn't have to consider node flattener, or the way to expand
 * or collapse. The expansion/collapsion will be handled by TreeControl and each non-leaf node.
 */ export class MatTreeNestedDataSource < T > extends DataSource < T > { _data = new BehaviorSubject < T [ ] > ( [ ] ) ; /**
     * Data for the nested tree
     */ get data ( ) { return this . _data . value ; } set data ( value ) { this . _data . next ( value ) ; } connect ( collectionViewer ) { return merge ( ... [ collectionViewer . viewChange , this . _data ] ) . pipe ( map ( ( ) => { return this . data ; } ) ) ; } disconnect ( ) { } }