65528: Renaming/Moving according to feedback; style and links added; chevrons fixed

This commit is contained in:
Marie Verdonck
2019-10-11 17:37:43 +02:00
parent 79424ac108
commit 3daf35e4a4
8 changed files with 243 additions and 228 deletions

View File

@@ -0,0 +1,33 @@
import {CommunityListAdapter, FlatNode} from './community-list-adapter';
import {CollectionViewer, DataSource} from '@angular/cdk/typings/collections';
import {BehaviorSubject, Observable,} from 'rxjs';
import {finalize, take,} from 'rxjs/operators';
export class CommunityListDatasource implements DataSource<FlatNode> {
private communityList$ = new BehaviorSubject<FlatNode[]>([]);
private loading$ = new BehaviorSubject<boolean>(false);
constructor(private communityListService: CommunityListAdapter) {
}
connect(collectionViewer: CollectionViewer): Observable<FlatNode[]> {
this.loadCommunities(null);
return this.communityList$.asObservable();
}
loadCommunities(expandedNodes: FlatNode[]) {
this.loading$.next(true);
this.communityListService.loadCommunities(expandedNodes).pipe(
take(1),
finalize(() => this.loading$.next(false)),
).subscribe((flatNodes: FlatNode[]) => this.communityList$.next(flatNodes));
}
disconnect(collectionViewer: CollectionViewer): void {
this.communityList$.complete();
this.loading$.complete();
}
}