statelyai / xstate

Actor-based state management & orchestration for complex app logic.
https://stately.ai/docs
MIT License
26.98k stars 1.24k forks source link

Add ability to spawn actor from any logic #4724

Open davidkpiano opened 8 months ago

davidkpiano commented 8 months ago

This PR adds the ability for any actor logic to spawn an actor, which is a core tenet of the actor model.

changeset-bot[bot] commented 8 months ago

⚠️ No Changeset found

Latest commit: 9a695175695f56856323eb671688c51558347c84

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

codesandbox-ci[bot] commented 8 months ago

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.

davidkpiano commented 2 months ago

There is a substantial problem with this PR that is somewhat mentioned in this comment here:

https://github.com/statelyai/xstate/blob/91549ce8a6a5105b3d354ca442ea5c058e58e206/packages/core/src/createActor.ts#L588-L592

When the parent actor gets stopped its children should get stopped too. There is no mechanism implemented here that would achieve this for this new functionality.

831aeec