cogwheel
TypeScript icon, indicating that this package has built-in type declarations

4.2.6 • Public • Published

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.

Getting started

Guards

Actions

Hierarchical machines

Front-end framework implementation

State machine examples

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 }) {}

Package Sidebar

Install

npm i cogwheel

Weekly Downloads

25

Version

4.2.6

License

MIT

Unpacked Size

7.29 kB

Total Files

4

Last publish

Collaborators

  • kevtiq