mirror of
https://github.com/wassname/DefinitelyTyped.git
synced 2026-08-24 11:29:30 +08:00
18 lines
781 B
TypeScript
18 lines
781 B
TypeScript
/// <reference path="state-machine.d.ts" />
|
|
|
|
var fsm = StateMachine.create({
|
|
initial: 'green',
|
|
events: [
|
|
{ name: 'warn', from: 'green', to: 'yellow' },
|
|
{ name: 'panic', from: 'yellow', to: 'red' },
|
|
{ name: 'calm', from: 'red', to: 'yellow' },
|
|
{ name: 'clear', from: 'yellow', to: 'green' }
|
|
],
|
|
callbacks: {
|
|
onpanic: function (event, from, to, msg) { alert('panic! ' + msg); },
|
|
onclear: function (event, from, to, msg) { alert('thanks to ' + msg); },
|
|
ongreen: function (event, from, to) { document.body.className = 'green'; },
|
|
onyellow: function (event, from, to) { document.body.className = 'yellow'; },
|
|
onred: function (event, from, to) { document.body.className = 'red'; },
|
|
}
|
|
}); |