0.0.28 • Published 2 years ago

hine v0.0.28

Weekly downloads
-
License
MIT
Repository
-
Last release
2 years ago

Hine

A JavaScript state machine library.

Install

npm install hine

Getting started

import { h } from 'hine';

// Compound states can have child states.
const toggle = h.compound({
	// The first state is the default initial state.
	states: {
		// Atomic states are leaf nodes. They do not have children.
		inactive: h.atomic({
			on: { toggle: 'active' },
		}),
		active: h.atomic({
			on: { toggle: 'inactive' },
		}),
	},
});

toggle.subscribe((alsoToggle) => {
	// toggle === alsoToggle
	console.log({ state: toggle.state.name });
	// { state: null };
})

toggle.start();
// { state: 'inactive' };

toggle.dispatch('toggle');
// { state: 'active' };
0.0.26

2 years ago

0.0.27

2 years ago

0.0.28

2 years ago

0.0.25

2 years ago

0.0.24

2 years ago

0.0.23

2 years ago

0.0.22

2 years ago

0.0.21

2 years ago

0.0.20

2 years ago

0.0.18

2 years ago

0.0.19

2 years ago

0.0.10

3 years ago

0.0.11

3 years ago

0.0.12

3 years ago

0.0.13

3 years ago

0.0.14

3 years ago

0.0.15

3 years ago

0.0.9

3 years ago

0.0.16

3 years ago

0.0.8

3 years ago

0.0.7

3 years ago

0.0.6

3 years ago

0.0.5

3 years ago

0.0.4

3 years ago

0.0.3

3 years ago

0.0.2

3 years ago

0.0.1

3 years ago