SnapshotService
Defined in: packages/save/src/snapshot/SnapshotService.ts:40
Orchestrates full game-state serialization and hydration.
Type Parameters
Section titled “Type Parameters”TSlots
Section titled “TSlots”TSlots extends UntypedSlots = UntypedSlots
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new SnapshotService<
TSlots>(storage,context,namespace?):SnapshotService<TSlots>
Defined in: packages/save/src/snapshot/SnapshotService.ts:47
Parameters
Section titled “Parameters”storage
Section titled “storage”context
Section titled “context”EngineContext
namespace?
Section titled “namespace?”string = "yage"
Returns
Section titled “Returns”SnapshotService<TSlots>
Methods
Section titled “Methods”deleteData()
Section titled “deleteData()”deleteData<
K>(slot):void
Defined in: packages/save/src/snapshot/SnapshotService.ts:165
Delete user data from the given slot.
Type Parameters
Section titled “Type Parameters”K extends string
Parameters
Section titled “Parameters”K
Returns
Section titled “Returns”void
deleteSnapshot()
Section titled “deleteSnapshot()”deleteSnapshot(
slot):void
Defined in: packages/save/src/snapshot/SnapshotService.ts:153
Delete a snapshot from the given slot.
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”void
exportData()
Section titled “exportData()”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.
Type Parameters
Section titled “Type Parameters”K extends string
Parameters
Section titled “Parameters”K
Returns
Section titled “Returns”TSlots[K] | null
exportSnapshot()
Section titled “exportSnapshot()”exportSnapshot(
slot):GameSnapshot|null
Defined in: packages/save/src/snapshot/SnapshotService.ts:96
Export a previously saved snapshot from the given slot.
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”GameSnapshot | null
hasData()
Section titled “hasData()”hasData<
K>(slot):boolean
Defined in: packages/save/src/snapshot/SnapshotService.ts:160
Check if user data exists in the given slot.
Type Parameters
Section titled “Type Parameters”K extends string
Parameters
Section titled “Parameters”K
Returns
Section titled “Returns”boolean
hasSnapshot()
Section titled “hasSnapshot()”hasSnapshot(
slot):boolean
Defined in: packages/save/src/snapshot/SnapshotService.ts:148
Check if a snapshot exists in the given slot.
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”boolean
importData()
Section titled “importData()”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.
Type Parameters
Section titled “Type Parameters”K extends string
Parameters
Section titled “Parameters”K
TSlots[K]
Returns
Section titled “Returns”void
importSnapshot()
Section titled “importSnapshot()”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.
Parameters
Section titled “Parameters”string
snapshot
Section titled “snapshot”Returns
Section titled “Returns”Promise<void>
loadData()
Section titled “loadData()”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.
Type Parameters
Section titled “Type Parameters”K extends string
Parameters
Section titled “Parameters”K
Returns
Section titled “Returns”TSlots[K] | null
loadSnapshot()
Section titled “loadSnapshot()”loadSnapshot(
slot):Promise<void>
Defined in: packages/save/src/snapshot/SnapshotService.ts:87
Load a snapshot from the given slot, rebuilding the scene stack.
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”Promise<void>
registerSnapshotExtra()
Section titled “registerSnapshotExtra()”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.
Parameters
Section titled “Parameters”string
contributor
Section titled “contributor”Returns
Section titled “Returns”void
saveData()
Section titled “saveData()”saveData<
K>(slot,data):void
Defined in: packages/save/src/snapshot/SnapshotService.ts:120
Save arbitrary structured data to a named slot.
Type Parameters
Section titled “Type Parameters”K extends string
Parameters
Section titled “Parameters”K
TSlots[K]
Returns
Section titled “Returns”void
saveSnapshot()
Section titled “saveSnapshot()”saveSnapshot(
slot):void
Defined in: packages/save/src/snapshot/SnapshotService.ts:78
Save a snapshot of the current scene stack to the given slot.
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”void
unregisterSnapshotExtra()
Section titled “unregisterSnapshotExtra()”unregisterSnapshotExtra(
key):void
Defined in: packages/save/src/snapshot/SnapshotService.ts:71
Remove a previously registered contributor.
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”void