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

[core] Add ability to spawn actors in lazy initial context #2366

Merged
merged 4 commits into from
Jul 1, 2021

Conversation

davidkpiano
Copy link
Member

Actors can now be spawned directly in the initial machine.context using lazy initialization, avoiding the need for intermediate states and unsafe typings for immediately spawned actors:

const machine = createMachine<{ ref: ActorRef<SomeEvent> }>({
  context: () => ({
    ref: spawn(anotherMachine, 'some-id') // spawn immediately!
  })
  // ...
});

@changeset-bot
Copy link

changeset-bot bot commented Jul 1, 2021

🦋 Changeset detected

Latest commit: 1a978a0

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

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

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

@davidkpiano davidkpiano requested a review from Andarist July 1, 2021 03:04
@davidkpiano davidkpiano merged commit 9b456be into main Jul 1, 2021
This was referenced Jul 1, 2021
@Andarist Andarist deleted the davidkpiano/lazy-initial-context 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.

None yet

2 participants