1
0

added missing tests and docs

This commit is contained in:
lotte
2019-03-14 11:14:59 +01:00
parent 4c150988e2
commit 917c00f8fb
4 changed files with 83 additions and 19 deletions

View File

@@ -65,18 +65,10 @@ export class ObjectCacheService {
/**
* Get an observable of the object with the specified UUID
*
* The type needs to be specified as well, in order to turn
* the cached plain javascript object in to an instance of
* a class.
*
* e.g. getByUUID('c96588c6-72d3-425d-9d47-fa896255a695', Item)
*
* @param uuid
* The UUID of the object to get
* @param type
* The type of the object to get
* @return Observable<T>
* An observable of the requested object
* @return Observable<NormalizedObject<T>>
* An observable of the requested object in normalized form
*/
getObjectByUUID<T extends CacheableObject>(uuid: string): Observable<NormalizedObject<T>> {
return this.store.pipe(
@@ -86,6 +78,14 @@ export class ObjectCacheService {
)
}
/**
* Get an observable of the object with the specified selfLink
*
* @param selfLink
* The selfLink of the object to get
* @return Observable<NormalizedObject<T>>
* An observable of the requested object in normalized form
*/
getObjectBySelfLink<T extends CacheableObject>(selfLink: string): Observable<NormalizedObject<T>> {
return this.getBySelfLink(selfLink).pipe(
map((entry: ObjectCacheEntry) => {
@@ -105,6 +105,14 @@ export class ObjectCacheService {
);
}
/**
* Get an observable of the object cache entry with the specified selfLink
*
* @param selfLink
* The selfLink of the object to get
* @return Observable<ObjectCacheEntry>
* An observable of the requested object cache entry
*/
getBySelfLink(selfLink: string): Observable<ObjectCacheEntry> {
return this.store.pipe(
select(entryFromSelfLinkSelector(selfLink)),
@@ -113,12 +121,28 @@ export class ObjectCacheService {
);
}
/**
* Get an observable of the request's uuid with the specified selfLink
*
* @param selfLink
* The selfLink of the object to get
* @return Observable<string>
* An observable of the request's uuid
*/
getRequestUUIDBySelfLink(selfLink: string): Observable<string> {
return this.getBySelfLink(selfLink).pipe(
map((entry: ObjectCacheEntry) => entry.requestUUID),
distinctUntilChanged());
}
/**
* Get an observable of the request's uuid with the specified uuid
*
* @param uuid
* The uuid of the object to get
* @return Observable<string>
* An observable of the request's uuid
*/
getRequestUUIDByObjectUUID(uuid: string): Observable<string> {
return this.store.pipe(
select(selfLinkFromUuidSelector(uuid)),