Skip to main content

Class: IndexedDbAssetStore<T>

Defined in: src/lib/storage/index.ts:328

Keeps assets of one kind (e.g. brush presets) in the browser's IndexedDB database (DATABASE_NAME), under a name (like IndexedDbSettingsStore's), each in its own record so saving one doesn't rewrite the others.

Example​

const store = new IndexedDbAssetStore<BrushPreset>("brushes");
await store.put(myPreset);

Type Parameters​

T​

T extends Asset<unknown>

Implements​

Constructors​

Constructor​

new IndexedDbAssetStore<T>(kind, name?, factory?): IndexedDbAssetStore<T>

Defined in: src/lib/storage/index.ts:342

Parameters​

kind​

"brushes" | "palettes" | "profiles"

the kind of asset

name?​

string = DEFAULT_SETTINGS_NAME

the settings' name the assets belong to (DEFAULT_SETTINGS_NAME by default)

factory?​

IDBFactory = indexedDB

the IndexedDB to use (the browser's by default)

Returns​

IndexedDbAssetStore<T>

Properties​

kind​

readonly kind: "brushes" | "palettes" | "profiles"

Defined in: src/lib/storage/index.ts:331


name​

readonly name: string

Defined in: src/lib/storage/index.ts:333

Methods​

list()​

list(): Promise<unknown[]>

Defined in: src/lib/storage/index.ts:352

The saved assets (untrusted: check them before using them), in the order they were first saved

Returns​

Promise<unknown[]>

Implementation of​

AssetStoreLike.list


put()​

put(asset): Promise<void>

Defined in: src/lib/storage/index.ts:364

Save an asset, replacing one with the same ID

Parameters​

asset​

T

Returns​

Promise<void>

Implementation of​

AssetStoreLike.put


remove()​

remove(id): Promise<void>

Defined in: src/lib/storage/index.ts:382

Delete an asset

Parameters​

id​

string

Returns​

Promise<void>

Implementation of​

AssetStoreLike.remove