xstate@6.0.0-alpha.40
Pre-release
Pre-release
·
0 commits
to main
since this release
Minor Changes
-
107d0c2: Represent historical machine versions with Standard Schema snapshot and event
descriptors instead of retaining their executable machines. Versioned machines
expose the samesnapshotSchemaandeventSchemainterface. Machine-backed
snapshot schemas default omitted history and timer records during migration.const versions = machineVersions([ { id: 'checkout', version: '1', snapshotSchema: checkoutV1Snapshot, eventSchema: checkoutV1Event }, checkoutV2 ]); const snapshot = await versions.migrateSnapshot(persisted, { to: '2', migrations: { '1': (snapshot) => ({ ...snapshot, context: { total: snapshot.context.count } }) } });
Patch Changes
-
2e77ff6:
actor.getPersistedSnapshot()is now typed to the actor’s logic, so persist/restore round-trips throughcreateActor(logic, { snapshot })no longer require a cast. Restoring a snapshot into a machine with a differentidis a type error, while snapshots from other versions of the same machine remain assignable (for runtime migration viamigrate).const actor = createActor(machine).start(); const snapshot = actor.getPersistedSnapshot(); // No cast needed: const restored = createActor(machine, { snapshot }).start();