0.1.0-alpha.3 • Published 1 year ago

@simple-state-machine/core v0.1.0-alpha.3

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

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 to dark or vice versa.
  • State diagram looks something like this for it: toggle-sm
  • 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

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