JSFiddle - React, Tailwind, and code Playground
by ifandelse
HTML
<script src="https://rawgit.com/lodash/lodash/2.4.1/dist/lodash.js"></script>
<script src="https://rawgit.com/ifandelse/machina.js/master/lib/machina.js"></script>
JavaScript
var fsm = new machina.BehavioralFsm({
initialState: "start",
states: {
start: {
_onEnter: function( client ) {
client.hasBeenStarted = true;
},
finishIt: function( client ) {
this.transition( client, "finished" );
}
},
finished: {
_onEnter: function( client ) {
client.hasFinished = true;
}
}
},
process: function( client ) {
this.handle( client, "finishIt" );
}
});
var clientA = {};
fsm.process( clientA );
console.log( JSON.stringify( clientA, null, 2 ) );