Skip to content

Install

Terminal window
npm install @dunky-dev/state-machine
import { machine } from '@dunky-dev/state-machine'
const toggle = machine({
initial: 'off',
context: {},
states: {
off: { on: { flip: { target: 'on' } } },
on: { on: { flip: { target: 'off' } } },
},
})
toggle.start()
toggle.send({ type: 'flip' })
toggle.state // 'on'