-
Notifications
You must be signed in to change notification settings - Fork 1
A JavaScript finite state machine
License
mschuerig/jsfsm
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
JavaScript Finite State Machine Builder ======================================= Version 0.2, 2007-12-30 This script embeds in JavaScript a domain-specific language -- a fluent interface, really -- for describing and building simple finite state machines. See the source code of spec/fsm.html and the files in examples for how it is supposed to work. Here's just a quick motivational example: var Machine = FSM.build(function(fsm) { with (fsm) { onUnexpectedEvent(function() { ... }); state('start', 'initial') .event('go') .goesTo('middle') .doing(function() { ... }) .doing('phew') .event('run') .goesTo('finish') .onExiting(function() { ... }); state('middle') .onUnexpectedEvent(function() { ... }) .onEntering(function() { ... }) .event('back') .goesTo('start') .onlyIf(function() { return true_or_false }) .event('go') .goesTo('finish'); state('finish', 'final'); }}); function TestMachine() {} // amend TestMachine.prototype here all the way you want TestMachine.prototype.phew = function() { ... }; TestMachine.prototype = new Machine(TestMachine.prototype); == Changes === 0.2.2 (2007-12-30) Include examples in dist. === 0.2.1 (2007-12-30) Corrected version in Rakefile. === 0.2 (2007-12-30) - Accessors for successorStates and expectedEvents - Machine-global onEntering, onExiting actions - Drag & Drop example === 0.1.1 (2007-12-23) Add FSM.build() as suggested by Nicolás Sanguinetti. === 0.1 (2007-12-22) First release. Copyright (c) 2007, Michael Schuerig, [email protected]
About
A JavaScript finite state machine
Resources
License
Stars
Watchers
Forks
Packages 0
No packages published