66391: expandedNodes (&loadingNode) is now retrieved/sent to the store

at component initialisation/destruction so the state of the tree persists
& documentation
This commit is contained in:
Marie Verdonck
2019-11-26 17:16:21 +01:00
parent eaf0911e2e
commit 9bd1933548
8 changed files with 406 additions and 256 deletions

View File

@@ -3,6 +3,12 @@ import { CollectionViewer, DataSource } from '@angular/cdk/typings/collections';
import { BehaviorSubject, Observable, } from 'rxjs';
import { finalize, take, } from 'rxjs/operators';
/**
* DataSource object needed by a CDK Tree to render its nodes.
* The list of FlatNodes that this DataSource object represents gets created in the CommunityListService at
* the beginning (initial page-limited top communities) and re-calculated any time the tree state changes
* (a node gets expanded or page-limited result become larger by triggering a show more node)
*/
export class CommunityListDatasource implements DataSource<FlatNode> {
private communityList$ = new BehaviorSubject<FlatNode[]>([]);
@@ -12,7 +18,6 @@ export class CommunityListDatasource implements DataSource<FlatNode> {
}
connect(collectionViewer: CollectionViewer): Observable<FlatNode[]> {
this.loadCommunities(null);
return this.communityList$.asObservable();
}