Skip to main content

AsyncStorageAdapter

Defined in: node_modules/achievements-engine/dist/index.d.ts:523

Implements

  • AchievementStorage

Constructors

Constructor

new AsyncStorageAdapter(asyncStorage, options?): AsyncStorageAdapter

Defined in: node_modules/achievements-engine/dist/index.d.ts:531

Parameters

asyncStorage

AsyncAchievementStorage

options?
onError?

(error) => void

Returns

AsyncStorageAdapter

Methods

clear()

clear(): void

Defined in: node_modules/achievements-engine/dist/index.d.ts:577

SYNC CLEAR: Clears cache immediately, clears storage in background

Returns

void

Implementation of

AchievementStorage.clear


flush()

flush(): Promise<void>

Defined in: node_modules/achievements-engine/dist/index.d.ts:582

Wait for all pending writes to complete (useful for testing/cleanup) NOT part of AchievementStorage interface - utility method

Returns

Promise<void>


getMetrics()

getMetrics(): AchievementMetrics

Defined in: node_modules/achievements-engine/dist/index.d.ts:560

SYNC READ: Returns cached metrics immediately Cache is loaded eagerly during construction

Returns

AchievementMetrics

Implementation of

AchievementStorage.getMetrics


getSnapshot()

getSnapshot(): AsyncStorageSnapshot

Defined in: node_modules/achievements-engine/dist/index.d.ts:555

Return a defensive copy of the cached storage state.

Returns

AsyncStorageSnapshot


getUnlockedAchievements()

getUnlockedAchievements(): string[]

Defined in: node_modules/achievements-engine/dist/index.d.ts:569

SYNC READ: Returns cached unlocked achievements immediately

Returns

string[]

Implementation of

AchievementStorage.getUnlockedAchievements


isLoaded()

isLoaded(): boolean

Defined in: node_modules/achievements-engine/dist/index.d.ts:551

Whether the initial async storage read has completed.

Returns

boolean


ready()

ready(): Promise<AsyncStorageSnapshot>

Defined in: node_modules/achievements-engine/dist/index.d.ts:547

Wait until the initial async storage read has populated the cache.

Returns

Promise<AsyncStorageSnapshot>


setMetrics()

setMetrics(metrics): void

Defined in: node_modules/achievements-engine/dist/index.d.ts:565

SYNC WRITE: Updates cache immediately, writes to storage in background Uses optimistic updates - assumes write will succeed

Parameters

metrics

AchievementMetrics

Returns

void

Implementation of

AchievementStorage.setMetrics


setUnlockedAchievements()

setUnlockedAchievements(achievements): void

Defined in: node_modules/achievements-engine/dist/index.d.ts:573

SYNC WRITE: Updates cache immediately, writes to storage in background

Parameters

achievements

string[]

Returns

void

Implementation of

AchievementStorage.setUnlockedAchievements