Open endash opened 13 years ago
Could you expand on what you are trying to accomplish.
As I understand it, this is what he wants to do:
App.statechart = SC.Statechart.create({
rootState: SC.State.design({
initialSubstate: 'CHILD',
PARENT: SC.State.design({
enterState: function() { console.log("PARENT:enterState()"),
CHILD: SC.State.design({
enterState: function() { console.log("CHILD:enterState()"),
exitState: function() { console.log("CHILD:exitState()"),
doSomething: function() { this.gotoState('PARENT')
})
})
})
});
After calling App.statechart.initStatechart()
, the following should be logged:
PARENT:enterState()
CHILD:enterState()
So far, so good. Now call App.statechart.sendAction('doSomething')
. This is what endash expects to be logged:
CHILD:exitState()
This is what is actually logged:
CHILD:exitState()
PARENT:enterState()
In other words, even though the PARENT state has already been entered (and is not being exited), enterState()
is called again. Seems pretty clear to me that this is a bug in the statechart framework.
But the inverse (moving from a parent state to a substate invoking exitState) isn't true. This wreaks havoc if you're doing complimentary things in those methods.