Black Lives Matter. Support the Equal Justice Initiative.


Fast 1kB functional library for creating Finite State Machines

# guard

A guard is a method that determines if a transition can proceed. Returning true allows the transition to occur, returning false prevents it from doing so and leaves the state in its current place.

import { createMachine, guard, state, transition } from 'robot3';

// Only allow submission if a login and password is entered.
function canSubmit(ctx) {
return ctx.login && ctx.password;

const machine = createMachine({
idle: state(
transition('submit', 'complete',
complete: state()