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

Open
wants to merge 57 commits into
base: main
Choose a base branch
from
Open

[core] Transition function #4954

wants to merge 57 commits into from

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: 96f4ac4

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 💜

}
if (typeof action === 'function' && !('resolve' in action)) {
const type = `${this.id}|${kind}:${i}`;
this.machine.implementations.actions[type] = action as any;
Copy link
Member

Choose a reason for hiding this comment

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

  1. I don't particularly like that we are writing to this object because it might be shared among different machines in some way and we might potentially leak things between instances
  2. i'd be wary of the code here, I wonder if this gets "fixed" somehow but I think there might run into stale closure hazard by resolving this here and caching it

@Jamscott
Copy link

Is there any update on the status of this, as I really need this with the deprecation of starting interpreter at a state on server side machines

@davidkpiano
Copy link
Member Author

Is there any update on the status of this, as I really need this with the deprecation of starting interpreter at a state on server side machines

We're planning on merging it soon (cc. @Andarist )

actorScope.system.scheduler.cancel(actorScope.self, resolvedSendId);
// actorScope.system.scheduler.cancel(actorScope.self, resolvedSendId);
Copy link
Contributor

Choose a reason for hiding this comment

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

Should executeCancel do something?

Comment on lines -90 to +93
actorScope.defer(() => {
const self = actorScope.self;
actorScope.system.scheduler.schedule(self, self, event, delay, id);
});
// actorScope.defer(() => {
// const self = actorScope.self;
// actorScope.system.scheduler.schedule(self, self, event, delay, id);
// });
Copy link
Contributor

Choose a reason for hiding this comment

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

Same thing here with executeRaise

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