added normalized models and builders

This commit is contained in:
Art Lowel
2017-04-20 14:21:21 +02:00
parent 8e0d2bac9b
commit c2da34b305
30 changed files with 642 additions and 160 deletions

View File

@@ -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
*