1.1.1 • Published 2 years ago
stachine v1.1.1
Stachine
A TypeScript state machine with events and effects
Gist
import { StateMachine } from 'stachine';
type States = { type: 'Home' } | { type: 'Bed' } | { type: 'Work' };
type Events = { type: 'Commute' } | { type: 'Wake' } | { type: 'Sleep' };
const machine = new StateMachine<States, Events>(
{ type: 'Home' },
{
onEvent: {
Commute: {
Home: () => ({ type: 'Work' }),
Work: () => ({ type: 'Home' }),
},
Sleep: {
Home: () => ({ type: 'Bed' }),
},
Wake: {
Bed: (effect) => {
effect(() => {
console.log(`Good night`);
});
return { type: 'Home' };
},
},
},
}
);
2.0.0-1
2 years ago
1.1.1
2 years ago
1.1.0
2 years ago
2.0.0-0
2 years ago
1.0.11
2 years ago
1.0.10
2 years ago
1.0.9
2 years ago
1.0.8
2 years ago
1.0.7
2 years ago
1.0.6
2 years ago
1.0.5
2 years ago
1.0.4
3 years ago
1.0.2
3 years ago
1.0.0-19
3 years ago
1.0.1
3 years ago
1.0.0
3 years ago
1.0.3
3 years ago
1.0.0-20
3 years ago
1.0.0-21
3 years ago
1.0.0-18
3 years ago
1.0.0-17
5 years ago
1.0.0-16
5 years ago
1.0.0-14
5 years ago
1.0.0-15
5 years ago
1.0.0-13
5 years ago
1.0.0-11
5 years ago
1.0.0-12
5 years ago
1.0.0-10
5 years ago
1.0.0-9
5 years ago
1.0.0-8
5 years ago
1.0.0-7
5 years ago
1.0.0-6
5 years ago
1.0.0-5
5 years ago
1.0.0-4
5 years ago
1.0.0-3
5 years ago
1.0.0-2
5 years ago
1.0.0-1
5 years ago
1.0.0-0
5 years ago