mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-19 07:53:02 +00:00
remove zone.runOutsideAngular from requestService.configure due to AoT
build issues
This commit is contained in:
@@ -1,4 +1,3 @@
|
|||||||
import { NgZone } from '@angular/core';
|
|
||||||
import * as ngrx from '@ngrx/store';
|
import * as ngrx from '@ngrx/store';
|
||||||
import { ActionsSubject, Store } from '@ngrx/store';
|
import { ActionsSubject, Store } from '@ngrx/store';
|
||||||
import { cold, getTestScheduler, hot } from 'jasmine-marbles';
|
import { cold, getTestScheduler, hot } from 'jasmine-marbles';
|
||||||
@@ -63,7 +62,6 @@ describe('RequestService', () => {
|
|||||||
objectCache,
|
objectCache,
|
||||||
uuidService,
|
uuidService,
|
||||||
store,
|
store,
|
||||||
new NgZone({}),
|
|
||||||
undefined
|
undefined
|
||||||
);
|
);
|
||||||
serviceAsAny = service as any;
|
serviceAsAny = service as any;
|
||||||
|
@@ -80,7 +80,6 @@ export class RequestService {
|
|||||||
constructor(private objectCache: ObjectCacheService,
|
constructor(private objectCache: ObjectCacheService,
|
||||||
private uuidService: UUIDService,
|
private uuidService: UUIDService,
|
||||||
private store: Store<CoreState>,
|
private store: Store<CoreState>,
|
||||||
private zone: NgZone,
|
|
||||||
private indexStore: Store<MetaIndexState>) {
|
private indexStore: Store<MetaIndexState>) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -148,30 +147,21 @@ export class RequestService {
|
|||||||
* @param {RestRequest} request The request to send out
|
* @param {RestRequest} request The request to send out
|
||||||
*/
|
*/
|
||||||
configure<T extends CacheableObject>(request: RestRequest): void {
|
configure<T extends CacheableObject>(request: RestRequest): void {
|
||||||
/**
|
const isGetRequest = request.method === RestRequestMethod.GET;
|
||||||
* Since this method doesn't return anything, is used very often and has
|
if (!isGetRequest || request.forceBypassCache || !this.isCachedOrPending(request)) {
|
||||||
* problems with actions being dispatched to the store but not reduced before
|
this.dispatchRequest(request);
|
||||||
* that info is needed again, we may as well run it in a separate zone. That way
|
if (isGetRequest) {
|
||||||
* it won't block the UI, and actions have a better chance of being already
|
this.trackRequestsOnTheirWayToTheStore(request);
|
||||||
* processed when the next isCachedOrPending call comes
|
|
||||||
*/
|
|
||||||
this.zone.runOutsideAngular(() => {
|
|
||||||
const isGetRequest = request.method === RestRequestMethod.GET;
|
|
||||||
if (!isGetRequest || request.forceBypassCache || !this.isCachedOrPending(request)) {
|
|
||||||
this.dispatchRequest(request);
|
|
||||||
if (isGetRequest) {
|
|
||||||
this.trackRequestsOnTheirWayToTheStore(request);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
this.getByHref(request.href).pipe(
|
|
||||||
filter((entry) => hasValue(entry)),
|
|
||||||
take(1)
|
|
||||||
).subscribe((entry) => {
|
|
||||||
return this.store.dispatch(new AddToIndexAction(IndexName.UUID_MAPPING, request.uuid, entry.request.uuid))
|
|
||||||
}
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
});
|
} else {
|
||||||
|
this.getByHref(request.href).pipe(
|
||||||
|
filter((entry) => hasValue(entry)),
|
||||||
|
take(1)
|
||||||
|
).subscribe((entry) => {
|
||||||
|
return this.store.dispatch(new AddToIndexAction(IndexName.UUID_MAPPING, request.uuid, entry.request.uuid))
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Reference in New Issue
Block a user