Skip to content

Latest commit

 

History

History
38 lines (28 loc) · 671 Bytes

README.md

File metadata and controls

38 lines (28 loc) · 671 Bytes

Hine

A JavaScript state machine library.

Install

npm install hine

Getting started

import { atomic, compound, emitEvent, matches, resolveState } from 'hine';

const toggleConfig = compound('toggle', {
	initial: 'inactive',
	children: [
		atomic('inactive', {
			on: { toggle: 'active' },
		}),
		atomic('active', {
			on: { toggle: 'inactive' },
		}),
	],
});
const myToggle = resolveState(toggleConfig);

matches(myToggle, 'toggle.inactive'); // true

emitEvent(myToggle, 'toggle');

matches(myToggle, 'toggle.active'); // true