3.0.1 • Published 2 years ago

st8 v3.0.1

Weekly downloads
2,123
License
MIT
Repository
github
Last release
2 years ago

st8 Build Status

St8 is a tiny state machine for structural describing behavior of components.

Usage

$ npm install st8
var State = require('st8');

var state = new State({
	a: {
		enter: () => {
			...
		},
		exit: () => {
			...
		}
	},

	// shortcut for enter/exit
	b: [ () => {}, () => {} ],

	// enter shortcut, forwards to state d
	c: () => 'd',

	// shorter cut, redirects to state a
	d: 'a',

	// any other state
	_: 'a'
});


//enter state 'a', invoke corresponding callbacks
state.set('a');

//get current state
state.get(); // 'a'

API

let state = new State(states , context)

Create a new state machine based on the states object. Optionally pass a context for callbacks.

state.get()

Get current state.

state.set(value)

Transition to a new state, invoking necessary callbacks.

NPM

2.1.0

2 years ago

3.0.1

2 years ago

3.0.0

2 years ago

2.0.0

5 years ago

1.1.1

8 years ago

1.1.0

9 years ago

1.0.5

9 years ago

1.0.4

9 years ago

1.0.3

9 years ago

1.0.2

9 years ago

1.0.1

9 years ago

1.0.0

9 years ago

0.1.27

9 years ago

0.1.26

9 years ago

0.1.25

9 years ago

0.1.24

9 years ago

0.1.23

9 years ago

0.1.22

9 years ago

0.1.21

9 years ago

0.1.19

10 years ago

0.1.18

10 years ago

0.1.17

10 years ago

0.1.16

10 years ago

0.1.15

10 years ago

0.1.14

10 years ago

0.1.13

10 years ago

0.1.12

10 years ago

0.1.11

10 years ago

0.1.10

10 years ago

0.1.9

10 years ago

0.1.8

10 years ago

0.1.7

10 years ago

0.1.6

10 years ago

0.1.5

10 years ago

0.1.4

10 years ago

0.1.3

10 years ago

0.1.2

10 years ago

0.1.1

10 years ago

0.1.0

10 years ago

0.0.7

10 years ago

0.0.6

10 years ago

0.0.5

10 years ago

0.0.3

10 years ago

0.0.2

10 years ago