nanostate icon indicating copy to clipboard operation
nanostate copied to clipboard

Guard action

Open rook2pawn opened this issue 4 years ago • 1 comments

@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 avatar Sep 16 '21 09:09 rook2pawn

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
  });

rook2pawn avatar May 22 '22 04:05 rook2pawn