Closed ghost closed 13 years ago
Any time you get this particular error is means that you are trying to go from one state to another state that happen to have a common ancestor state (the state that will be pivoted on) where its immediate substates are concurrent. This is not allowed. For your root state, is the substatesAreConcurrent
property set to true?
Yeah exactly.
But according to the guide: https://github.com/FrozenCanuck/Ki/wiki/Example-of-When-to-Use-Concurrent-States-Over-History-States this should be allowed.
I have a structure like the one in the guide.
You are allowed concurrent substates, but take a look at the example code carefully. Notice that for both concurrent states, neither have substates that go to a state that sits outside of their respective parent states. concurrent states showPageState
and menuState
contain substates that are related closely to each.
When working with substates that descend from a parent state that is concurrent to other states at the same level, those substates should only ever make a reference to other substates that also descend from the same parent state. Concurrent states should be seen as modularizing states into groups where one module is independent of the other module.
This is why you are getting an error message since you have one substate trying to make a transition to another substate both of which belong to their own respective parent states that are directly concurrent to each other. That is not valid when you construct your statechart.
Yeah I get you, thats why it's weird because I have done exactly what you did on the tutorial.
Take a look at this:
Sorry for bothering again =)
But I still don't get why I get the Pivot error because I'm just transitioning between substates that reside under the same parent that is concurrent with one other state in the same level. This should not be violating the principle that you described both in the tutorial and in the mailing list reply.
Which state is actually invoking gotoState
to go to sessionState.checkingUserSession.route1
, and what is that state's parent state?
I have recreated it for easier debugging. Please have a look at: https://gist.github.com/838832
You can also paste this directly in into a Sproutcore app for debugging.
I get this error message:
ERROR Ki.Statechart
Looked at your code.
First, you don't have to do explicit console.log statements. You can just set the statechart's trace
property to true and it will pump out trace statements to your browser's JS console.
As for your states, I noticed that your session's substates get into an infinite loop:
session: Ki.State.design({
initialSubstate: "sessionProxy",
sessionProxy: Ki.State.design({
enterState: function() {
Test.statechart.gotoState("checkingIfUserIsLoggedInAtYi")
}
}),
checkingIfUserIsLoggedInAtYi: Ki.State.design({
enterState: function() {
Test.statechart.gotoState("sessionProxy")
}
})
})
I'm assuming your left out various logic that decides on when to switch states instead of just going ahead and doing so when you enter each.
I still need to know what state you are trying to go from. What state is it that calls gotoState that gives you this error? Actually, I need to go back and update the error message so it provides more detail.
Get the latest Ki code. I just made an update that will provide some more details about the invalid state transition. Show me what error you get now.
Thanks for the "trace" tip. Saves me a lot of time! =)
Yes I left out some logic so in reality it won't get into an infinite loop.
I updated the Ki and now it says:
ERROR Ki.Statechart
That's what I don't get it. sessionProxy can go to showingSearch but not the other way around. Must be something with current Pivot state. But I didn't get how that is working.
It seems that the problem was instead of:
Testsc.statechart.gotoState()
I have to type:
this.gotoState()
Finally :)
When I goto a state with gotoState() I get:
ERROR Ki.Statechart: Can not go to state Ki.State<sessionState.checkingUserSession.route1, sc704>. Pivot state Ki.State<ROOT_STATE, sc695> has concurrent substates.
Is there a way to work around this?