Skip to content

vyckes/cogwheel

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

89 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Cogwheel - simple JavaScript state machines

Node version NPM Downloads Minified size License: MIT

Simple finite state machines that can be used for state/process management.

Principles

Cogwheel is build around the following principles around state machines, and the library should be used as such:

  • State transitions are synchronous & fire & forget by design;
  • State transisions should not have side-effects, except for debugging purposes (e.g. console-log);
  • The context should be serializable;
  • All state & context mutations should be owned by the machine and its actions. This means as much (business) logic as possible should be included in the machine and its actions.

Migration v3.x.x > v4.x.x

  • Remove all import { send, assign } from 'cogwheel';;
  • Replace input parameters of all actions
const exampleAction({ state, event, assign, send }) {}