fsm-node
A minimalist Node.js finite state machine.
Install
$ npm install fsm-node
Usage
fsm-node
has a simple API that expects a set of states and a set of events that define how the event machine moves through the different states. Invalid configuration objects passed into fsm
will raise an error with helpful usage information.
const fsm = ; const machine = ; machine; machine; console;console; machineevent'submit'; console; machineevent'delete';console; machineevent'submit';
This produces:
draft
false
EVENT: previousState: draft, action: submit, newState: pending
pending
EVENT: previousState: pending, action: delete, newState: deleted
true
IGNORED: state: deleted, action: submit