Skip to content

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.

1 participant