Skip to content

SnapshotService

Defined in: packages/save/src/snapshot/SnapshotService.ts:40

Orchestrates full game-state serialization and hydration.

TSlots extends UntypedSlots = UntypedSlots

new SnapshotService<TSlots>(storage, context, namespace?): SnapshotService<TSlots>

Defined in: packages/save/src/snapshot/SnapshotService.ts:47

SnapshotStorage

EngineContext

string = "yage"

SnapshotService<TSlots>

deleteData<K>(slot): void

Defined in: packages/save/src/snapshot/SnapshotService.ts:165

Delete user data from the given slot.

K extends string

K

void


deleteSnapshot(slot): void

Defined in: packages/save/src/snapshot/SnapshotService.ts:153

Delete a snapshot from the given slot.

string

void


exportData<K>(slot): TSlots[K] | null

Defined in: packages/save/src/snapshot/SnapshotService.ts:136

Read data from a slot for external use (cloud upload, file export). Alias for loadData.

K extends string

K

TSlots[K] | null


exportSnapshot(slot): GameSnapshot | null

Defined in: packages/save/src/snapshot/SnapshotService.ts:96

Export a previously saved snapshot from the given slot.

string

GameSnapshot | null


hasData<K>(slot): boolean

Defined in: packages/save/src/snapshot/SnapshotService.ts:160

Check if user data exists in the given slot.

K extends string

K

boolean


hasSnapshot(slot): boolean

Defined in: packages/save/src/snapshot/SnapshotService.ts:148

Check if a snapshot exists in the given slot.

string

boolean


importData<K>(slot, data): void

Defined in: packages/save/src/snapshot/SnapshotService.ts:141

Write externally-sourced data into a slot. Alias for saveData — no version check or hydration.

K extends string

K

TSlots[K]

void


importSnapshot(slot, snapshot): Promise<void>

Defined in: packages/save/src/snapshot/SnapshotService.ts:101

Import a snapshot into the given slot and hydrate the scene stack.

string

GameSnapshot

Promise<void>


loadData<K>(slot): TSlots[K] | null

Defined in: packages/save/src/snapshot/SnapshotService.ts:125

Load structured data from a named slot. Returns null if not found.

K extends string

K

TSlots[K] | null


loadSnapshot(slot): Promise<void>

Defined in: packages/save/src/snapshot/SnapshotService.ts:87

Load a snapshot from the given slot, rebuilding the scene stack.

string

Promise<void>


registerSnapshotExtra(key, contributor): void

Defined in: packages/save/src/snapshot/SnapshotService.ts:66

Register a plugin to contribute extra data to every snapshot under key. The contributor’s serialize() is invoked during saveSnapshot, and its restore(data) runs after every scene + entity in the snapshot has been hydrated. Re-registering an existing key replaces the previous contributor.

string

SnapshotContributor

void


saveData<K>(slot, data): void

Defined in: packages/save/src/snapshot/SnapshotService.ts:120

Save arbitrary structured data to a named slot.

K extends string

K

TSlots[K]

void


saveSnapshot(slot): void

Defined in: packages/save/src/snapshot/SnapshotService.ts:78

Save a snapshot of the current scene stack to the given slot.

string

void


unregisterSnapshotExtra(key): void

Defined in: packages/save/src/snapshot/SnapshotService.ts:71

Remove a previously registered contributor.

string

void