Last change
on this file was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
3.7 KB
|
Rev | Line | |
---|
[6a3a178] | 1 | /**
|
---|
| 2 | * @license
|
---|
| 3 | * Copyright Google LLC All Rights Reserved.
|
---|
| 4 | *
|
---|
| 5 | * Use of this source code is governed by an MIT-style license that can be
|
---|
| 6 | * found in the LICENSE file at https://angular.io/license
|
---|
| 7 | */
|
---|
| 8 | import { DataSource } from '@angular/cdk/collections';
|
---|
| 9 | import { BehaviorSubject, merge } from 'rxjs';
|
---|
| 10 | import { map } from 'rxjs/operators';
|
---|
| 11 | /**
|
---|
| 12 | * Data source for nested tree.
|
---|
| 13 | *
|
---|
| 14 | * The data source for nested tree doesn't have to consider node flattener, or the way to expand
|
---|
| 15 | * or collapse. The expansion/collapsion will be handled by TreeControl and each non-leaf node.
|
---|
| 16 | */
|
---|
| 17 | export class MatTreeNestedDataSource extends DataSource {
|
---|
| 18 | constructor() {
|
---|
| 19 | super(...arguments);
|
---|
| 20 | this._data = new BehaviorSubject([]);
|
---|
| 21 | }
|
---|
| 22 | /**
|
---|
| 23 | * Data for the nested tree
|
---|
| 24 | */
|
---|
| 25 | get data() { return this._data.value; }
|
---|
| 26 | set data(value) { this._data.next(value); }
|
---|
| 27 | connect(collectionViewer) {
|
---|
| 28 | return merge(...[collectionViewer.viewChange, this._data])
|
---|
| 29 | .pipe(map(() => this.data));
|
---|
| 30 | }
|
---|
| 31 | disconnect() {
|
---|
| 32 | // no op
|
---|
| 33 | }
|
---|
| 34 | }
|
---|
| 35 | //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibmVzdGVkLWRhdGEtc291cmNlLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vLi4vLi4vLi4vc3JjL21hdGVyaWFsL3RyZWUvZGF0YS1zb3VyY2UvbmVzdGVkLWRhdGEtc291cmNlLnRzI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