Sets responseMsToLive to zero in some dataService methods and adds ability to reset the responseMsToLive value in subclasses.

This commit is contained in:
Michael W Spalti
2019-09-16 10:00:45 -07:00
parent d449bd70a0
commit a50e568899
5 changed files with 11 additions and 8 deletions

View File

@@ -49,7 +49,10 @@ export abstract class DataService<T extends CacheableObject> {
protected abstract notificationsService: NotificationsService;
protected abstract http: HttpClient;
protected abstract comparator: ChangeAnalyzer<T>;
protected resetMsToLive = false;
/**
* Allows subclasses to reset the response cache time.
*/
protected resetMsToLive: number;
public abstract getBrowseEndpoint(options: FindAllOptions, linkPath?: string): Observable<string>
@@ -132,7 +135,7 @@ export abstract class DataService<T extends CacheableObject> {
.subscribe((href: string) => {
const request = new FindAllRequest(this.requestService.generateRequestId(), href, options);
if (this.resetMsToLive) {
request.responseMsToLive = 0;
request.responseMsToLive = this.resetMsToLive;
}
this.requestService.configure(request);
});
@@ -158,7 +161,7 @@ export abstract class DataService<T extends CacheableObject> {
.subscribe((href: string) => {
const request = new FindByIDRequest(this.requestService.generateRequestId(), href, id);
if (this.resetMsToLive) {
request.responseMsToLive = 0;
request.responseMsToLive = this.resetMsToLive;
}
this.requestService.configure(request);
});
@@ -169,7 +172,7 @@ export abstract class DataService<T extends CacheableObject> {
findByHref(href: string, options?: HttpOptions): Observable<RemoteData<T>> {
const request = new GetRequest(this.requestService.generateRequestId(), href, null, options);
if (this.resetMsToLive) {
request.responseMsToLive = 0;
request.responseMsToLive = this.resetMsToLive;
}
this.requestService.configure(request);
return this.rdbService.buildSingle<T>(href);

View File

@@ -20,7 +20,7 @@ import { DSOChangeAnalyzer } from '../data/dso-change-analyzer.service';
@Injectable()
export class WorkflowItemDataService extends DataService<WorkflowItem> {
protected linkPath = 'workflowitems';
protected resetMsToLive = true;
protected resetMsToLive = 0;
constructor(
protected comparator: DSOChangeAnalyzer<WorkflowItem>,

View File

@@ -20,7 +20,7 @@ import { WorkspaceItem } from './models/workspaceitem.model';
@Injectable()
export class WorkspaceitemDataService extends DataService<WorkspaceItem> {
protected linkPath = 'workspaceitems';
protected resetMsToLive = true;
protected resetMsToLive = 0;
constructor(
protected comparator: DSOChangeAnalyzer<WorkspaceItem>,

View File

@@ -22,7 +22,7 @@ import { ProcessTaskResponse } from './models/process-task-response';
@Injectable()
export class ClaimedTaskDataService extends TasksService<ClaimedTask> {
protected resetMsToLive = true;
protected resetMsToLive = 0;
/**
* The endpoint link name

View File

@@ -27,7 +27,7 @@ export class PoolTaskDataService extends TasksService<PoolTask> {
*/
protected linkPath = 'pooltasks';
protected resetMsToLive = true;
protected resetMsToLive = 0;
/**
* Initialize instance variables