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] Transition function #4954

Merged
merged 98 commits into from
Nov 12, 2024
Merged

[core] Transition function #4954

merged 98 commits into from
Nov 12, 2024

Conversation

davidkpiano
Copy link
Member

This PR adds the transition(…) function for returning a [snapshot, actions] tuple given the machine, state, and event.

Its main use-case is for server-side workflows and a pure way of handling state transitions for actor logic.

Copy link

changeset-bot bot commented Jun 26, 2024

🦋 Changeset detected

Latest commit: 9ee7564

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

This PR includes changesets to release 6 packages
Name Type
xstate Minor
@xstate/graph Major
@xstate/react Major
@xstate/solid Major
@xstate/svelte Major
@xstate/vue 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

@with-heart
Copy link
Contributor

Just a reminder to remove commented lines before merging 💜

packages/core/src/types.ts Outdated Show resolved Hide resolved
Comment on lines 1856 to 1863
action.exec?.(
{
...action.info,
self: actor,
system: actor.system
},
action.params
);
Copy link
Member

Choose a reason for hiding this comment

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

@davidkpiano this is missing action lookup in machine.implementations.actions. You can't rely on .exec being available if the goal is to have serializable actions. In fact, I'd probably just forbid combining inline actions with machine.executeAction. It should be an invariant that to use this API all actions must be declared explicitly in machine.implementations.actions. It's impossible to resolve an enqueued inline action, they are not discoverable in the static config at all. So it would be best to forbid all inline actions to make the rules clear around this.

Copy link
Member Author

Choose a reason for hiding this comment

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

We fixed this, right?

@Andarist Andarist force-pushed the davidkpiano/transition branch from ba900db to ca2977f Compare October 25, 2024 21:21
packages/core/src/types.ts Outdated Show resolved Hide resolved
@davidkpiano davidkpiano merged commit 8c4b706 into main Nov 12, 2024
1 check passed
@davidkpiano davidkpiano deleted the davidkpiano/transition branch November 12, 2024 13:23
@github-actions github-actions bot mentioned this pull request Nov 12, 2024
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.

4 participants