UNPKG

ng-indexed-db

Version:

An IndexedDB Angular module wrapped in RXJS

50 lines (49 loc) 1.73 kB
import { Observable } from 'rxjs'; import { BehaviorSubject } from 'rxjs/internal/BehaviorSubject'; import { NgConnection } from '../types/conecction.type'; import { NgDataBase } from '../types/database.type'; import { IndexedDatabase } from '../indexed-database'; export declare class NgDatabaseFactory { /** Emits an event when all databases recive has been generated */ connectionsReady: BehaviorSubject<any>; /** Indexed database connection factory */ private factory; /** List of all connections handled by the service */ private connections; /** Default connection name */ private defaultConnectionName; /** * Sends the database metadata to create. * Once it has been completed, emits the * connectionsReady event * @param databases Databases metadata */ createConnnections(databases: NgDataBase[]): void; /** * Find a database connection by name. If there isn't * a database name takes the default database name * @param dbName Name of the database alias */ getDatabase(dbName?: string): IndexedDatabase; /** * Open a database connection * @param dbName name of the database * @param version version of the database */ open(dbName: string, version?: number): Observable<OpenConnectionResponse>; /** * Generates an Observable collection of database connections * @param Databases metadata */ createDataBases(databases: NgDataBase[]): Observable<NgConnection>; /** * Generates a sigle database conecction client */ private createConnection; } interface OpenConnectionResponse { success: boolean; upgraded: boolean; result: IDBDatabase; } export {};