frpfsm (FRP Finite State Machine)
A small and simple Functionally Reactive Programming (streams) based state machine with a nice API for defining and transitioning states. Built on top of kefir.js.
Concept
Each state is a factory function that takes initial data and returns a stream that emits a single event when it wants to transition to a different state, specifying the transition name and exit data. frpfsm connects all the state streams together.
Usage
Initializing your states and transitions:
frpfsm; frpfsm; // etc...
Define your states:
{ // do other state stuff... // return stream that emmits a transition event when the play button is clicked return Kefir ;};
Start the machine:
var debug = true;frpfsmstart"Preload" startingValue debug;
See example.js
for a complete example.