🎲 mchine
A Simple State Machine
Why?
Because State machine are sexy, and easy to use. Using a state machine will change how you think and develop a Front-end application. Think more on your view's state instead of his transactions, this will reduce a lot of the if else and make the code more maintanable.
Install
npm install mchine
How to use
; const stateMachineSchema = initial: "idle" states: idle: events: login: target: "sending" sending: events: success: target: "idle" error: target: "error" error: {} ; const stateMachine = ; stateMachine; // idle stateMachine;stateMachine; // sending API // idle ; // error
How to import
Browser (Using modules)
Browser (UMD)
Transpilers (Babel, Rollup, Typescript, ...)
; // Some magic code ✨...
Node
const mchine = ; // Some magic code ✨...
References
- Implemention of MChine follows the main algorithm of the SCXML spec from the W3C