Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow existing actors in spawn() to be referenced by name #2374

Merged
merged 2 commits into from
Jul 7, 2021

Conversation

davidkpiano
Copy link
Member

Existing actors can now be identified in spawn(...) calls by providing an id. This allows them to be referenced by string:

const machine = createMachine({
  context: () => ({
    someRef: spawn(someExistingRef, 'something')
  }),
  on: {
    SOME_EVENT: {
      actions: send('AN_EVENT', { to: 'something' })
    }
  }
});

@changeset-bot
Copy link

changeset-bot bot commented Jul 3, 2021

🦋 Changeset detected

Latest commit: 1def6cf

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
xstate Patch

Not sure what this means? Click here to learn what changesets are.

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

@mattpocock
Copy link
Contributor

Does this also make them available in service.children.get('something')

@davidkpiano
Copy link
Member Author

Does this also make them available in service.children.get('something')

Yes it does. But maybe not on state.children['something'], will investigate.

@davidkpiano davidkpiano merged commit a5a572d into main Jul 7, 2021
This was referenced Jul 7, 2021
@Andarist Andarist deleted the davidkpiano/named-existing-actors branch March 22, 2023 15:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants