Skip to content

ecs-persistence: apply a snapshot's values onto an existing entity (a persisted setting on a startup entity) #249

Closed

Description

@krisnye

Summary

Spawning from a snapshot with match keeps the world's values for what it matches, and nothing applies a snapshot's values onto an existing entity. So an entity the app's own startup system creates (and persistence should only update) can't be a persisted setting.

Case (mecs, @adobe/ecs-persistence 0.1.0)

The camera's orbit (target, distance, angles) is a component of an entity that spawnOrbitView makes at startup. We want it saved as a setting (inSettings, kept on the machine, shared by tabs). Restoring with spawn({ world, snapshot, entities: false, match }) either leaves the startup value (match keeps the world's) or, without match, spawns a second view.

Requested

An option to apply the snapshot's values onto the matched entity: spawn({ ..., match, update: true }), or a separate apply({ world, snapshot, match }), writing the snapshot's persisted components onto the entity that match finds, and leaving other components as they are.

Notes

Settings already work for resources; this is the component half.

Activity

  1. krisnye commented on Nov 1, 2026

    @krisnye
    CollaboratorAuthor

    Addressed in #250 (Adobe-Firefly/ecs#9) as an option on spawn rather than a separate apply, so the entity map and reference rewriting stay one pass: spawn({ world, snapshot, match, update: true }) writes a matched row's saved components onto the entity it matches, as commands.add would, leaving its other components. Core commands.spawnTables takes the same update. The settings chapter of the persistence guide restores a startup entity's component this way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions