0.1.0-alpha.3 • Published 1 year ago
@simple-state-machine/core v0.1.0-alpha.3
Simple State Machine
Installation
npm i @simple-state-machine/core
Quick glance
- A simplest state machine can be a "Light<>Dark" Mode toggling. On click of button is toggle from
light
todark
or vice versa. - State diagram looks something like this for it:
Code for the above machine using the library looks like
import {createState, createEvents, createContext, MachineConfig} from 'simple-state-machine' const states = createStates('light', 'dark'); const events = createEvents('TOGGLE'); const context = createContext({}); const ThemeMachine = new MachineConfig(states, context, events); const {whenIn} = ThemeMachine; whenIn('light').on('TOGGLE').moveTo('dark'); whenIn('dark').on('TOGGLE').moveTo('light');
Examples
- Toggle Theme Machine
- Throttling Machine in typescript
API
0.1.0-alpha.3
1 year ago
0.1.0-alpha.1
1 year ago
0.1.0-alpha.2
1 year ago
0.1.0-alpha.0
2 years ago
0.0.23
2 years ago
0.0.22
2 years ago
0.0.20
2 years ago
0.0.21
2 years ago
0.0.19
2 years ago
0.0.16
2 years ago
0.0.17
2 years ago
0.0.18
2 years ago
0.0.14
2 years ago
0.0.6
2 years ago
0.0.5
2 years ago
0.0.4
2 years ago
0.0.3
2 years ago
0.0.2
2 years ago
0.0.1
2 years ago