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

Edit after events #4521

Merged
merged 8 commits into from
Nov 30, 2023
Merged

Edit after events #4521

merged 8 commits into from
Nov 30, 2023

Conversation

davidkpiano
Copy link
Member

The event type of internal after events changed from xstate.after(1000)#some.state.id to xstate.after.1000.#some.state.id for consistency.

Copy link

changeset-bot bot commented Nov 29, 2023

🦋 Changeset detected

Latest commit: 1c48110

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

Copy link

codesandbox-ci bot commented Nov 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 1c48110:

Sandbox Source
XState Example Template Configuration
XState React Template Configuration

Comment on lines 11 to 13
export function createAfterEvent(delayRef: number | string, id?: string) {
const idSuffix = id ? `#${id}` : '';
return { type: `xstate.after(${delayRef})${idSuffix}` } as const;
return { type: `xstate.after.${delayRef}.${idSuffix}` } as const;
Copy link
Member

Choose a reason for hiding this comment

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

id is always provided from what I can see, let's make that argument required and drop this conditional expression (just inline the id directly in the type)

davidkpiano and others added 2 commits November 30, 2023 08:06
Co-authored-by: Mateusz Burzyński <mateuszburzynski@gmail.com>
const idSuffix = id ? `#${id}` : '';
return { type: `xstate.after(${delayRef})${idSuffix}` } as const;
export function createAfterEvent(delayRef: number | string, id: string) {
return { type: `xstate.after.${delayRef}.#${id}` } as const;
Copy link
Member

Choose a reason for hiding this comment

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

I removed the # from the auto-generated invokeId. Should we do the same 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.

Sure; also in general, we just have to make sure that any . in places like delayRef are escaped and account for those; that's an edge-case though.

# Conflicts:
#	packages/core/src/stateUtils.ts
@davidkpiano davidkpiano merged commit 355e896 into next Nov 30, 2023
2 checks passed
@davidkpiano davidkpiano deleted the v5/edit-after-events branch November 30, 2023 15:29
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