SnapshotResolver
Defined in: packages/core/dist/index.d.ts:158
Passed to afterRestore hooks so user code can resolve entity references
that were captured as IDs at save time.
Methods
Section titled “Methods”entity()
Section titled “entity()”entity(
savedId):Entity|null
Defined in: packages/core/dist/index.d.ts:160
Resolve a save-time entity ID to the restored entity instance. Returns null if not found.
Parameters
Section titled “Parameters”savedId
Section titled “savedId”number
Returns
Section titled “Returns”Entity | null
handle()
Section titled “handle()”handle<
E>(savedId):EntityHandle<E> |undefined
Defined in: packages/core/dist/index.d.ts:175
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); }Type Parameters
Section titled “Type Parameters”E extends Entity = Entity
Parameters
Section titled “Parameters”savedId
Section titled “savedId”number | null | undefined
Returns
Section titled “Returns”EntityHandle<E> | undefined