You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
35 lines
655 B
TypeScript
35 lines
655 B
TypeScript
import { Machine, State, On, Do, Goto, Spawn, Unspawn } from '../index';
|
|
|
|
const beginTimer = (ctx:C, e:E)=>{};
|
|
|
|
type S = 'green' | 'yellow' | 'red';
|
|
type E = ['entry',null] | ['timer-finished',null];
|
|
type C = null;
|
|
|
|
const machine =
|
|
Machine<S,E,C>(
|
|
State('green',
|
|
On('entry',
|
|
Do(beginTimer)
|
|
),
|
|
On('timer-finished',
|
|
Goto('yellow')
|
|
)
|
|
),
|
|
State('yellow',
|
|
On('entry',
|
|
Do(beginTimer)
|
|
),
|
|
On('timer-finished',
|
|
Goto('red')
|
|
)
|
|
),
|
|
State('red',
|
|
On('entry',
|
|
Do(beginTimer)
|
|
),
|
|
On('timer-finished',
|
|
Goto('green')
|
|
)
|
|
),
|
|
); |