I'm trying to get to grips with the workings of machina.js.
I have definied state1
which does it's own thing, and it produces a variable someVar
, and then it transitions to state2
.
How can I pass someVar
as an argument to state2
?
var fsm = new machina.Fsm({
initialState: "uninitialized",
states: {
uninitialized: {},
state1: {
_onEnter: function() {
var someVar = "..."; // Stuff.
this.transition("state2");
}
},
state2: {
_onEnter: function() {
// someVar as argument somehow...?
console.log(someVar);
}
}
}
});
You could probably do something like this:
You'd then call the code by: