/** * Options passed to `IStoreProp`. */ export interface ILocalStorageOptions { default?: any; } export type StorageValueType = | 'string' | 'bool' | 'number' | 'date' | 'object' | 'null'; /** * A stored value. */ export interface ILocalStorageValue { type: StorageValueType; value: any; } /** * A platform independent persistent store. */ export interface ILocalStorage { getItem(key: string): Promise; setItem(key: string, value: any): Promise; removeItem(key: string): Promise; } /** * An event that is fired when the local storage is accessed. */ export interface ILocalStorageChangedEvent { key: string; value: any; type: StorageValueType; } export type LocalStoragePropertyFunc = ( value?: T | null, options?: ILocalStorageOptions, ) => Promise; export type LocalStorageProp = LocalStoragePropertyFunc & { key: string; isProp: boolean; }; export type LocalStoragePropertyFactory = ( key: string, defaultOptions?: ILocalStorageOptions, ) => LocalStorageProp;