Skip to content

SnapshotResolver

Defined in: Serializable.ts:10

Passed to afterRestore hooks so user code can resolve entity references that were captured as IDs at save time.

entity(savedId): Entity | null

Defined in: Serializable.ts:12

Resolve a save-time entity ID to the restored entity instance. Returns null if not found.

number

Entity | null


handle<E>(savedId): EntityHandle<E> | undefined

Defined in: Serializable.ts:27

Resolve a save-time entity ID to a handle on the restored entity — the load-side counterpart of entity.handle(). undefined when the id is null or not in the snapshot, which covers a reference that was already empty at save time, a target destroyed before the save, and a pool member the snapshot left out. Serialize the id as null when the handle is empty — an explicit value survives a JSON round trip, a missing key does not.

serialize() { return { targetId: this.target?.current?.id ?? null }; }
afterRestore(data, resolve) { this.target = resolve.handle<Enemy>(data.targetId); }

E extends Entity = Entity

number | null | undefined

EntityHandle<E> | undefined