UNPKG

@snap/camera-kit

Version:
20 lines 980 B
import { __awaiter } from "tslib"; import { Injectable } from "@snap/ts-inject"; import { persistentStoreError } from "../namedErrors"; import { getLogger } from "../logger/logger"; import { IndexedDBPersistence } from "../persistence/IndexedDBPersistence"; import { lensCoreFactory } from "../lens-core-module/loader/lensCoreFactory"; const logger = getLogger("LensPersistenceStore"); export const lensPersistenceStoreFactory = Injectable("lensPersistenceStore", [lensCoreFactory.token], (lensCore) => { const db = new IndexedDBPersistence({ databaseName: "lensPersistenceStore" }); lensCore.registerSavePersistentStoreCallback((id, data) => __awaiter(void 0, void 0, void 0, function* () { try { yield db.store(id, data); } catch (error) { logger.error(persistentStoreError(`Error occurred while storing data for lens ${id}.`, error)); } })); return db; }); //# sourceMappingURL=LensPersistenceStore.js.map