Finite State Machine (FSM)
Models state as discrete values with defined transitions. Useful for workflows like checkout processes or user authentication.
- Explicit state transitions
- Guards for conditional transitions
- Easy to test and visualize
const stateMachine = createMachine({
idle: { on: { START: 'loading' } },
loading: { on: { SUCCESS: 'done', ERROR: 'idle' } },
done: { type: 'final' }
});