mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 10:04:11 +00:00
[CST-6876] Refactoring in order to remove nested subscriptions
This commit is contained in:
@@ -120,11 +120,10 @@ export class SearchFacetFilterComponent implements OnInit, OnDestroy {
|
|||||||
this.searchOptions$.subscribe(() => this.updateFilterValueList()),
|
this.searchOptions$.subscribe(() => this.updateFilterValueList()),
|
||||||
this.refreshFilters.asObservable().pipe(
|
this.refreshFilters.asObservable().pipe(
|
||||||
filter((toRefresh: boolean) => toRefresh),
|
filter((toRefresh: boolean) => toRefresh),
|
||||||
).subscribe(() => {
|
mergeMap(() => this.retrieveFilterValues(false))
|
||||||
this.retrieveFilterValues(false);
|
).subscribe()
|
||||||
})
|
|
||||||
);
|
);
|
||||||
this.retrieveFilterValues();
|
this.retrieveFilterValues().subscribe();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -279,7 +278,7 @@ export class SearchFacetFilterComponent implements OnInit, OnDestroy {
|
|||||||
return getFacetValueForType(facet, this.filterConfig);
|
return getFacetValueForType(facet, this.filterConfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected retrieveFilterValues(useCachedVersionIfAvailable = true) {
|
protected retrieveFilterValues(useCachedVersionIfAvailable = true): Observable<RemoteData<PaginatedList<FacetValue>[]>> {
|
||||||
const facetValues$ = observableCombineLatest([this.searchOptions$, this.currentPage]).pipe(
|
const facetValues$ = observableCombineLatest([this.searchOptions$, this.currentPage]).pipe(
|
||||||
map(([options, page]) => {
|
map(([options, page]) => {
|
||||||
return { options, page };
|
return { options, page };
|
||||||
@@ -301,8 +300,7 @@ export class SearchFacetFilterComponent implements OnInit, OnDestroy {
|
|||||||
);
|
);
|
||||||
|
|
||||||
let filterValues = [];
|
let filterValues = [];
|
||||||
this.subs.push(
|
return facetValues$.pipe(
|
||||||
facetValues$.pipe(
|
|
||||||
mergeMap((facetOutcome) => {
|
mergeMap((facetOutcome) => {
|
||||||
const newValues$ = facetOutcome.values;
|
const newValues$ = facetOutcome.values;
|
||||||
|
|
||||||
@@ -333,8 +331,8 @@ export class SearchFacetFilterComponent implements OnInit, OnDestroy {
|
|||||||
});
|
});
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
})
|
}),
|
||||||
).subscribe((rd: RemoteData<PaginatedList<FacetValue>[]>) => {
|
tap((rd: RemoteData<PaginatedList<FacetValue>[]>) => {
|
||||||
this.animationState = 'ready';
|
this.animationState = 'ready';
|
||||||
this.filterValues$.next(rd);
|
this.filterValues$.next(rd);
|
||||||
})
|
})
|
||||||
|
Reference in New Issue
Block a user