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

fix: do not fire promise events after state changes #171

Closed
wants to merge 2 commits into from

Conversation

kybarg
Copy link
Contributor

@kybarg kybarg commented Jan 12, 2022

fixes #141

@kybarg
Copy link
Contributor Author

kybarg commented Jun 22, 2022

@matthewp any thoughts on this?

@matthewp
Copy link
Owner

Is this how Xstate works?

@kybarg
Copy link
Contributor Author

kybarg commented Jun 29, 2022

@matthewp Yes, here is an example https://codesandbox.io/s/suspicious-pare-137g4z

machine.js Outdated
.then(data => service.send({ type: 'done', data }))
.catch(error => service.send({ type: 'error', error }));
.then(data => {
if (machine.state.name === service.machine.state.name)
Copy link
Contributor

Choose a reason for hiding this comment

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

Since every step generates a new machine, wouldn't it be enough to compare the value of machine versus service.machine? It would address the case where the state machine has returned to the same state before the promise resolves.

@matthewp
Copy link
Owner

matthewp commented Nov 2, 2022

Sorry for the delay @kybarg, can you address @ehuelsmann's review and update the branch?

@kybarg
Copy link
Contributor Author

kybarg commented Nov 17, 2022

@matthewp done

@Hurtak
Copy link

Hurtak commented Sep 5, 2023

Could we merge and release this? It seems that the approach was approved, it was just never merged.

@ehuelsmann
Copy link
Contributor

@kybarg , this PR now has conflicts. Although it's unclear from @matthewp as far as merging is concerned, could you address the conflicts so merging is an option again?

@ehuelsmann
Copy link
Contributor

@matthewp, I don't mind updating this PR so you can include it in a next release. I'll need to create a new PR though, because I can't append to this one. Are you fine with that? Does it make sense for me to work on this?

@ehuelsmann ehuelsmann mentioned this pull request Nov 28, 2023
@matthewp
Copy link
Owner

@ehuelsmann yep, works for me

Copy link

changeset-bot bot commented Dec 4, 2023

⚠️ No Changeset found

Latest commit: 0b2caf1

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

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.

Cancel invokation events if already transitioned
4 participants