mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-14 05:23:06 +00:00
request.effects.ts pipeable operators error fix
This commit is contained in:
@@ -20,10 +20,10 @@ import { DSpaceRESTv2Serializer } from '../dspace-rest-v2/dspace-rest-v2.seriali
|
|||||||
import { NormalizedObjectFactory } from '../cache/models/normalized-object-factory';
|
import { NormalizedObjectFactory } from '../cache/models/normalized-object-factory';
|
||||||
import { catchError, flatMap, map, take, tap } from 'rxjs/operators';
|
import { catchError, flatMap, map, take, tap } from 'rxjs/operators';
|
||||||
|
|
||||||
export const addToResponseCacheAndCompleteAction = (request: RestRequest) =>
|
export const addToResponseCacheAndCompleteAction = (request: RestRequest, responseCache: ResponseCacheService, envConfig: GlobalConfig) =>
|
||||||
(source: Observable<ErrorResponse>): Observable<RequestCompleteAction> =>
|
(source: Observable<ErrorResponse>): Observable<RequestCompleteAction> =>
|
||||||
source.pipe(
|
source.pipe(
|
||||||
tap((response: RestResponse) => this.responseCache.add(request.href, response, this.EnvConfig.cache.msToLive)),
|
tap((response: RestResponse) => responseCache.add(request.href, response, envConfig.cache.msToLive)),
|
||||||
map((response: RestResponse) => new RequestCompleteAction(request.uuid))
|
map((response: RestResponse) => new RequestCompleteAction(request.uuid))
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -45,9 +45,9 @@ export class RequestEffects {
|
|||||||
}
|
}
|
||||||
return this.restApi.request(request.method, request.href, body).pipe(
|
return this.restApi.request(request.method, request.href, body).pipe(
|
||||||
map((data: DSpaceRESTV2Response) => this.injector.get(request.getResponseParser()).parse(request, data)),
|
map((data: DSpaceRESTV2Response) => this.injector.get(request.getResponseParser()).parse(request, data)),
|
||||||
addToResponseCacheAndCompleteAction(request),
|
addToResponseCacheAndCompleteAction(request, this.responseCache, this.EnvConfig),
|
||||||
catchError((error: RequestError) => Observable.of(new ErrorResponse(error)).pipe(
|
catchError((error: RequestError) => Observable.of(new ErrorResponse(error)).pipe(
|
||||||
addToResponseCacheAndCompleteAction(request)
|
addToResponseCacheAndCompleteAction(request, this.responseCache, this.EnvConfig)
|
||||||
))
|
))
|
||||||
);
|
);
|
||||||
})
|
})
|
||||||
|
Reference in New Issue
Block a user