Skip to content

Instantly share code, notes, and snippets.

@jbeard4
Last active December 14, 2015 02:49
Show Gist options
  • Save jbeard4/5016569 to your computer and use it in GitHub Desktop.
Save jbeard4/5016569 to your computer and use it in GitHub Desktop.
var sm = (function(){
//declare your variables
var sharedData = {};
//this is your public interface to the statechart model. regular module pattern
return {
sharedData : sharedData,
model : {
states : [
{
id : 'foo',
onEntry : function(){ sharedData.i = 1; },
transitions : [{ event : 't', target : 'bar' }]
},
{
id : 'bar'
onEntry : function(){
//this will print 2, because the sharedData.i has been incremeented outside of the statatechart
console.log(sharedData.i);
}
}
]
}
}
})()
var sc = new scion.Statechart(sm.model);
console.log(sc.sharedData.i); //should print 1
sc.sharedData.i++; //increment i
sc.gen('t')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment