mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-12 12:33:07 +00:00
added normalized models and builders
This commit is contained in:
24
src/app/core/cache/object-cache.service.ts
vendored
24
src/app/core/cache/object-cache.service.ts
vendored
@@ -60,6 +60,11 @@ export class ObjectCacheService {
|
||||
.map((entry: ObjectCacheEntry) => <T> Object.assign(new type(), entry.data));
|
||||
}
|
||||
|
||||
getBySelfLink<T extends CacheableObject>(href: string, type: GenericConstructor<T>): Observable<T> {
|
||||
return this.store.select<string>('core', 'index', 'href', href)
|
||||
.flatMap((uuid: string) => this.get(uuid, type))
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an observable for an array of objects of the same type
|
||||
* with the specified UUIDs
|
||||
@@ -104,6 +109,25 @@ export class ObjectCacheService {
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check whether the object with the specified self link is cached
|
||||
*
|
||||
* @param href
|
||||
* The self link of the object to check
|
||||
* @return boolean
|
||||
* true if the object with the specified self link is cached,
|
||||
* false otherwise
|
||||
*/
|
||||
hasBySelfLink(href: string): boolean {
|
||||
let result: boolean = false;
|
||||
|
||||
this.store.select<string>('core', 'index', 'href', href)
|
||||
.take(1)
|
||||
.subscribe((uuid: string) => result = this.has(uuid));
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check whether an ObjectCacheEntry should still be cached
|
||||
*
|
||||
|
Reference in New Issue
Block a user