UNPKG

@statezero/core

Version:

The type-safe frontend client for StateZero - connect directly to your backend models with zero boilerplate

76 lines (75 loc) 1.92 kB
/** * Simple IndexedDB key-value store with batched operations */ export class IndexedDBStore { constructor(dbName: any, options?: {}); dbName: any; storeName: any; batchDelay: any; version: any; resetOnErrors: any; pendingOps: any[]; activeCommit: Promise<void> | null; _destroyed: boolean; dbPromise: Promise<any>; /** * Attempt to open the database, with automatic recovery if it fails */ _openDatabaseWithRecovery(): Promise<any>; /** * Open the database */ _openDatabase(): Promise<any>; /** * Delete the database */ _deleteDatabase(): Promise<any>; /** * Retrieve a value by key */ get(key: any): Promise<any>; /** * Store a value with the given key */ set(key: any, value: any): Promise<any>; /** * Remove a key-value pair */ delete(key: any): Promise<any>; /** * Delete the entire database */ destroy(): Promise<void>; /** * Kick off a batch if none is running */ _startCommitIfNeeded(): Promise<void>; /** * Add this method to the IndexedDBStore class */ getAllKeys(): Promise<any>; /** * Get all entries from the store * @returns {Promise<Array<[any, any]>>} Array of [key, value] pairs */ getAll(): Promise<Array<[any, any]>>; /** * Execute all pending operations in one transaction */ _executeBatch(): Promise<void>; } export class Cache { constructor(dbName: any, options?: {}, onHydrated?: null); store: IndexedDBStore; localMap: Map<any, any>; hydrate(): Promise<void>; get(key: any): any; set(key: any, value: any): void; delete(key: any): void; getAllKeys(): Promise<any>; /** * Clear all entries from the cache * Clears the in-memory map and schedules deletion of all keys in IndexedDB */ clear(): void; }