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

Actions are not updated when the transition is to the same state #74

Open
good-idea opened this issue Aug 30, 2018 · 1 comment
Open
Labels

Comments

@good-idea
Copy link

good-idea commented Aug 30, 2018

With a statechart that looks like this, where an event triggers a transition to the same state, its associated actions are not updated unless transition is called with the second (data) argument.

const statechart = {
  initial: "login",
  states: {
    login: {
      on: {
        error: {
          login: {
            actions: ["showErrorMessage"]
          }
        },
        success: {
          welcome: {
            actions: ["showSuccessMessage"]
          }
        }
      }
    },
    welcome: {}
  }
};

doesn't work: transition('error')
works: transition('error', {})

Here is a reproduction.

Updated: this works if you pass in an empty object as the second arg to transition

@MicheleBertoli
Copy link
Owner

Thank you very much for opening this issue, providing a non-working example and a workaround, @good-idea.

I didn't consider the case where a transition goes back to the current state on purpose, and I strongly believe we should cover the case.
I left some comments in the PR, and I'm looking forward to merging it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants