mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 01:54:15 +00:00
trying to get request handling in the right order
This commit is contained in:
@@ -113,6 +113,7 @@ export class RemoteDataBuildService {
|
|||||||
href$ = observableOf(href$);
|
href$ = observableOf(href$);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
href$.subscribe(href => console.log('request url: ', href));
|
||||||
const requestEntry$ = href$.pipe(getRequestFromRequestHref(this.requestService));
|
const requestEntry$ = href$.pipe(getRequestFromRequestHref(this.requestService));
|
||||||
const tDomainList$ = requestEntry$.pipe(
|
const tDomainList$ = requestEntry$.pipe(
|
||||||
getResourceLinksFromResponse(),
|
getResourceLinksFromResponse(),
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
import { HttpClient } from '@angular/common/http';
|
import { HttpClient } from '@angular/common/http';
|
||||||
|
|
||||||
import { Observable } from 'rxjs';
|
import { Observable } from 'rxjs';
|
||||||
import { distinctUntilChanged, filter, find, first, map, mergeMap, switchMap, take } from 'rxjs/operators';
|
import { distinctUntilChanged, filter, find, first, map, mergeMap, switchMap, take, tap } from 'rxjs/operators';
|
||||||
import { Store } from '@ngrx/store';
|
import { Store } from '@ngrx/store';
|
||||||
|
|
||||||
import { hasValue, isNotEmpty, isNotEmptyOperator } from '../../shared/empty.util';
|
import { hasValue, isNotEmpty, isNotEmptyOperator } from '../../shared/empty.util';
|
||||||
@@ -184,20 +184,20 @@ export abstract class DataService<T extends CacheableObject> {
|
|||||||
* @return {Observable<RemoteData<PaginatedList<T>>}
|
* @return {Observable<RemoteData<PaginatedList<T>>}
|
||||||
* Return an observable that emits response from the server
|
* Return an observable that emits response from the server
|
||||||
*/
|
*/
|
||||||
protected searchBy(searchMethod: string, options: FindAllOptions = {}, refresh: boolean = false): Observable<RemoteData<PaginatedList<T>>> {
|
protected searchBy(searchMethod: string, options: FindAllOptions = {}): Observable<RemoteData<PaginatedList<T>>> {
|
||||||
|
|
||||||
const hrefObs = this.getSearchByHref(searchMethod, options);
|
const hrefObs = this.getSearchByHref(searchMethod, options);
|
||||||
|
|
||||||
hrefObs.pipe(
|
return hrefObs.pipe(
|
||||||
find((href: string) => hasValue(href)))
|
find((href: string) => hasValue(href)),
|
||||||
.subscribe((href: string) => {
|
switchMap((href: string) => {
|
||||||
if (refresh) {
|
|
||||||
this.requestService.removeByHrefSubstring(href);
|
this.requestService.removeByHrefSubstring(href);
|
||||||
|
const request = new FindAllRequest(this.requestService.generateRequestId(), href, options);
|
||||||
|
this.requestService.configure(request, true);
|
||||||
|
return this.rdbService.buildList<T>(href) as Observable<RemoteData<PaginatedList<T>>>
|
||||||
}
|
}
|
||||||
const request = new FindAllRequest(this.requestService.generateRequestId(), href, options);
|
)
|
||||||
this.requestService.configure(request, true);
|
);
|
||||||
});
|
|
||||||
return this.rdbService.buildList<T>(hrefObs) as Observable<RemoteData<PaginatedList<T>>>;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -225,7 +225,7 @@ export class RelationshipService extends DataService<Relationship> {
|
|||||||
} else {
|
} else {
|
||||||
findAllOptions.searchParams = searchParams;
|
findAllOptions.searchParams = searchParams;
|
||||||
}
|
}
|
||||||
return this.searchBy('byLabel', findAllOptions, true);
|
return this.searchBy('byLabel', findAllOptions);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -3,7 +3,7 @@ import { HttpHeaders } from '@angular/common/http';
|
|||||||
|
|
||||||
import { createSelector, MemoizedSelector, select, Store } from '@ngrx/store';
|
import { createSelector, MemoizedSelector, select, Store } from '@ngrx/store';
|
||||||
import { Observable, race as observableRace } from 'rxjs';
|
import { Observable, race as observableRace } from 'rxjs';
|
||||||
import { filter, map, mergeMap, take } from 'rxjs/operators';
|
import { filter, map, mergeMap, switchMap, take } from 'rxjs/operators';
|
||||||
import { cloneDeep, remove } from 'lodash';
|
import { cloneDeep, remove } from 'lodash';
|
||||||
|
|
||||||
import { AppState } from '../../app.reducer';
|
import { AppState } from '../../app.reducer';
|
||||||
|
Reference in New Issue
Block a user