More refactoring + reusing the server's store on the client

This commit is contained in:
Art Lowel
2017-03-02 13:36:40 +01:00
parent b0f25c4dae
commit 7745938027
27 changed files with 348 additions and 371 deletions

View File

@@ -1,11 +1,12 @@
import { ObjectCacheAction, ObjectCacheActionTypes, AddToObjectCacheAction, RemoveFromObjectCacheAction } from "./object-cache.actions";
import { hasValue } from "../../shared/empty.util";
import { CacheEntry } from "./cache-entry";
export interface CacheableObject {
uuid: string;
}
export interface ObjectCacheEntry {
export class ObjectCacheEntry implements CacheEntry {
data: CacheableObject;
timeAdded: number;
msToLive: number;
@@ -39,7 +40,7 @@ function addToObjectCache(state: ObjectCacheState, action: AddToObjectCacheActio
return Object.assign({}, state, {
[action.payload.objectToCache.uuid]: {
data: action.payload.objectToCache,
timeAdded: new Date().getTime(),
timeAdded: action.payload.timeAdded,
msToLive: action.payload.msToLive
}
});