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

Guard action #16

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Guard action #16

wants to merge 3 commits into from

Conversation

rook2pawn
Copy link

@goto-bus-stop Guard allows the user to define when a state should not be allowed to advanced to. The nice thing about this is that the logic between multiple machines can stay tightly coupled as part of attributes about the machine. Thus, the logic does not have to be managed by application state. Let me know if there is something I can improve or any feedback.

@rook2pawn
Copy link
Author

I've also included onchange to allow listening for arbitrary changes in state

  var machine = nanostate("green", {
    green: { timer: "yellow" },
    yellow: { timer: "red" },
    red: { timer: "green" },
  });
  machine.onchange((nextState) => {
// nextState == yellow
  });

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

1 participant