@bleckert/state
v0.3.0
Published
Simple state machine
Downloads
39
Readme
Install
npm i @bleckert/state
or yarn add @bleckert/state
Usage
import Machine from '@bleckert/state';
const machine = new Machine({
IDLE: {
on: {
send: 'SENDING',
},
},
SENDING: {
on: {
sent: 'SENT',
failed: 'ERROR',
},
},
SENT: {
final: true,
},
FAILED: {
on: {
retry: 'SENDING',
},
},
});
machine.onState('SENDING', console.log);
machine.dispatch('send');