UNPKG

@microsoft/windows-admin-center-sdk

Version:

Microsoft - Windows Admin Center Shell

39 lines (38 loc) 1.42 kB
import { Observable } from 'rxjs'; import { CachedDataStore } from './cached-data-store'; /** * Defines a single value data store using browser storage as the underlying storage mechanism * This is used as a base class for LocalDataStore and SessionDataStore which use LocalStorage and SessionStorage respectively */ export declare abstract class BrowserStorageDataStore<TData> extends CachedDataStore<TData, string> { protected storageKey: string; protected storage: Storage; /** * Initializes a new instance of DataStore<T> */ constructor(storageKey: string, storage: Storage); /** * Implementation to get the stored data */ protected getData(): Observable<string>; /** * Implementation to set the stored data */ protected setData(data: string): Observable<void>; /** * Implementation to clear the stored data */ protected clearData(): Observable<void>; /** * Transforms data in preparation for storage. Default behavior is no operation */ protected transformToStore(data: TData): string; /** * Transforms data in preparation for usage. Default behavior is no operation */ protected transformFromStore(storedData: string): TData; /** * Listens for when other windows have modified our storage key and emits when the stored data has changed. */ private listenForStorageChanges; }