Project Name | Stars | Downloads | Repos Using This | Packages Using This | Most Recent Commit | Total Releases | Latest Release | Open Issues | License | Language |
---|---|---|---|---|---|---|---|---|---|---|
Xstate | 23,131 | 6,706 | 474 | a day ago | 140 | September 09, 2022 | 239 | mit | TypeScript | |
State machines and statecharts for the modern web. | ||||||||||
Usestatemachine | 2,260 | 6 months ago | 10 | mit | TypeScript | |||||
The <1 kb state machine hook for React | ||||||||||
Microstates | 1,314 | 9 | 9 | a year ago | 88 | September 08, 2020 | 56 | mit | JavaScript | |
Composable state primitives for JavaScript | ||||||||||
Little State Machine | 1,269 | 2 months ago | 8 | mit | TypeScript | |||||
📠 React custom hook for persist state management | ||||||||||
Machinery | 470 | 1 | 10 days ago | 16 | November 16, 2019 | 10 | apache-2.0 | Elixir | ||
State machine thin layer for structs | ||||||||||
Beedle | 370 | 4 months ago | n,ull | mit | JavaScript | |||||
A tiny library inspired by Redux & Vuex to help you manage state in your JavaScript apps | ||||||||||
Python Statemachine | 366 | 1 | 2 | 6 days ago | 15 | January 23, 2020 | 2 | mit | Python | |
Python Finite State Machines made easy. | ||||||||||
Redux Machine | 338 | 1 | 3 | 3 years ago | 18 | December 13, 2017 | 5 | JavaScript | ||
A tiny library (12 lines) for creating state machines in Redux apps | ||||||||||
Pvm | 335 | 1 | 4 years ago | 22 | April 23, 2019 | 3 | mit | PHP | ||
Build workflows, activities, BPMN like processes, or state machines with PVM. | ||||||||||
Xstate Viz | 328 | 4 months ago | 83 | mit | TypeScript | |||||
Visualizer for XState machines |
Baahu is a small zero-dependency Moore machine-based UI framework for Javascript + TypeScript
Everything you need to know about Baahu is in the docs!
Try it out live on Code Sandbox!
You should read the docs, but if you want a sneak peek at what the API looks like, here a couple of example components:
import { b, machine, emit } from 'baahu';
const Toggle = machine({
id: 'toggle',
initial: 'inactive',
context: () => ({}),
when: {
inactive: { on: { TOGGLE: { to: 'active' } } },
active: { on: { TOGGLE: { to: 'inactive' } } },
},
render: state => (
<div>
<h3>{state}</h3>
<button onClick={() => emit({ type: 'TOGGLE' })}>Toggle</button>
</div>
),
});
A traffic light component that doesn't let you cross the street when it is red, and displays the # of times you crossed the street.
import { b, machine, emit } from 'baahu';
/** returns a function that is called by baahu. emit the
* provided event after the specified time */
function delayedEmit(event, delayMS) {
return () => setTimeout(() => emit(event, 'light'), delayMS);
}
/**
* you can make your own abstractions like `delayedEmit`
* for entry/exit/"do" actions.
*
* embracing js/ts (as opposed to shipping with every
* possible abstraction) keeps baahu fast and light!
*/
const Light = machine({
id: 'light',
initial: 'red',
context: () => ({
streetsCrossed: 0,
}),
when: {
red: {
entry: delayedEmit({ type: 'START' }, 3000),
on: {
START: {
to: 'green',
},
CROSS: {
do: () => alert('JAYWALKING'),
},
},
},
yellow: {
entry: delayedEmit({ type: 'STOP' }, 1500),
on: {
STOP: {
to: 'red',
},
CROSS: {
do: ctx => ctx.streetsCrossed++,
},
},
},
green: {
entry: delayedEmit({ type: 'SLOW_DOWN' }, 2500),
on: {
SLOW_DOWN: {
to: 'yellow',
},
CROSS: {
do: ctx => ctx.streetsCrossed++,
},
},
},
},
render: (state, ctx) => (
<div>
<h3>{state}</h3>
{/* this is a targeted event:
only the machine with the specified
id will be checked */}
<button onClick={() => emit({ type: 'CROSS' }, 'light')}>
Cross the Street
</button>
<p>Time(s) street crossed: {ctx.streetsCrossed}</p>
</div>
),
});