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

[v5] systemId for spawn() #3990

Merged
merged 3 commits into from
May 18, 2023
Merged

[v5] systemId for spawn() #3990

merged 3 commits into from
May 18, 2023

Conversation

davidkpiano
Copy link
Member

This PR adds systemId to the 2nd argument of spawn(logic, options?).

@changeset-bot
Copy link

changeset-bot bot commented Apr 29, 2023

🦋 Changeset detected

Latest commit: 0e1f370

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

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

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

@codesandbox-ci
Copy link

codesandbox-ci bot commented Apr 29, 2023

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 0e1f370:

Sandbox Source
XState Example Template Configuration
XState React Template Configuration

"--config",
"jest.config.js",
"--no-cache",
"--testTimeout=2147483647"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry @Andarist, I think this was a bad idea. With this test timeout, any failing test will now hang for a long time instead of timing out, making it very difficult to determine which test is failing.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's revert this change from here. I opened a PR here to add a second launch script - there will be one with the timeout and one without it.

@ghost
Copy link

ghost commented May 5, 2023

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

Review these changes using an interactive CodeSee Map

Legend

CodeSee Map legend

@@ -0,0 +1,19 @@
---
'xstate': major
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
'xstate': major
'xstate': patch

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't this technically be minor?

Also I've been wondering about how this works with the next branch. When I ran changesets add for #3997, it just assumed it was a major change for some reason.

Do the different versions have any effect when it's in prerelease mode?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't this technically be minor?

That works too. I suggest patch here since this was an oversight on our part. This kinda should be supported from the start. I don't mind using minor though - we'll have to clean up this changeset before releasing final v5 anyway (this particular changeset is only relevant for the prerelease)

When I ran changesets add for #3997, it just assumed it was a major change for some reason.

That's weird, it should allow u to select the type.

Do the different versions have any effect when it's in prerelease mode?

It's just for grouping them together. And all pending changesets are used to determine the next version - if we didn't have any major changesets then we would end up with xstate@4.38.0-beta.11 (or similar).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the explanation! Makes sense 👍

Comment on lines +5 to +19
You can now add a `systemId` to spawned actors to reference them anywhere in the system.

```ts
const machine = createMachine({
// ...
context: ({ spawn }) => ({
actorRef: spawn(
createMachine({
// ...
}),
{ systemId: 'actorRef' }
)
})
});
```
Copy link
Contributor

@with-heart with-heart May 17, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Showing how to reference the actor by systemId elsewhere in the system would add a lot of value here

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will do this in the docs

@davidkpiano davidkpiano merged commit fe6db14 into next May 18, 2023
@davidkpiano davidkpiano deleted the v5/spawn-systemid branch May 18, 2023 07:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants