xstate icon indicating copy to clipboard operation
xstate copied to clipboard

[v5] Actor reset

Open davidkpiano opened this issue 2 years ago • 3 comments

This PR introduces an actor.reset(persistedState?) method to reset an actor, either to its original initial state or a specified state. This can be a mechanism for actor supervision, where a parent actor can restart a failed actor.

The actor.reset method will:

  1. Stop the current actor
  2. Set its status to ActorStatus.NotStarted
  3. Initialize the actor's state to its initial state or the provided persistedState

Restarting an actor can be done via:

actor.reset();
actor.start();

davidkpiano avatar Mar 20 '23 13:03 davidkpiano

⚠️ No Changeset found

Latest commit: d3f88057e47f402649f35a994efa391725976146

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

changeset-bot[bot] avatar Mar 20 '23 13:03 changeset-bot[bot]

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit d3f88057e47f402649f35a994efa391725976146:

Sandbox Source
XState Example Template Configuration
XState React Template Configuration

codesandbox-ci[bot] avatar Mar 20 '23 13:03 codesandbox-ci[bot]

👇 Click on the image for a new way to code review

Review these changes using an interactive CodeSee Map

Legend

CodeSee Map legend

ghost avatar Mar 24 '23 00:03 ghost