UNPKG

@raona/sp

Version:

Raona utilities to work with Sharepoint using pnp/sp

33 lines (32 loc) 1.38 kB
export declare class PersistentStorageV2<T> { private storageKey; private expirationTime; private notifier; private subscription; constructor(storageKey: string, expirationTime: number); /** * Function to setup the persistent storage, only needed if you want/can retrieve the data, * if you only want to subscribe, call PersistentStorage.subscribe() instead and you will be * notified of changes on that data. * * @param callback Function to retrieve the data to be persisted on cache * @param expirationTime Persistance duration for the data retrieved by the callback, by default will use the one provided on the constructor. */ setup(callback: Function, expirationTime?: number): Promise<void>; get(): T; private getFromStorage; private getExpirationTime; set(data: T, expirationTime?: number): void; /** * You will be subscribed to data changes for this persistent storage, * only one subscription is allowed, for multiple subscriptions to the same key, * you will need multiple instances. * * @param callback Function to be called on cached data change. */ subscribe(callback: Function): void; /** * Call this for cleanup purposes, to clean up the subscription and avoid memory leaks. */ unsubscribe(): void; }