|
106 | 106 | return this.error(name, from, to, args, StateMachine.Error.INVALID_TRANSITION, "event " + name + " inappropriate in current state " + this.current); |
107 | 107 |
|
108 | 108 | if (false === StateMachine.beforeEvent(this, name, from, to, args)) |
109 | | - return StateMachine.CANCELLED; |
| 109 | + return StateMachine.Result.CANCELLED; |
110 | 110 |
|
111 | 111 | if (from === to) { |
112 | 112 | StateMachine.afterEvent(this, name, from, to, args); |
113 | | - return StateMachine.NOTRANSITION; |
| 113 | + return StateMachine.Result.NOTRANSITION; |
114 | 114 | } |
115 | 115 |
|
116 | 116 | // prepare a transition method for use EITHER lower down, or by caller if they want an async transition (indicated by an ASYNC return value from leaveState) |
|
121 | 121 | StateMachine.enterState( fsm, name, from, to, args); |
122 | 122 | StateMachine.changeState(fsm, name, from, to, args); |
123 | 123 | StateMachine.afterEvent( fsm, name, from, to, args); |
| 124 | + return StateMachine.Result.SUCCEEDED; |
124 | 125 | }; |
125 | 126 | this.transition.cancel = function() { // provide a way for caller to cancel async transition if desired (issue #22) |
126 | 127 | fsm.transition = null; |
|
130 | 131 | var leave = StateMachine.leaveState(this, name, from, to, args); |
131 | 132 | if (false === leave) { |
132 | 133 | this.transition = null; |
133 | | - return StateMachine.CANCELLED; |
| 134 | + return StateMachine.Result.CANCELLED; |
134 | 135 | } |
135 | | - else if ("async" === leave) { |
136 | | - return StateMachine.ASYNC; |
| 136 | + else if (StateMachine.ASYNC === leave) { |
| 137 | + return StateMachine.Result.ASYNC; |
137 | 138 | } |
138 | 139 | else { |
139 | 140 | if (this.transition) |
140 | | - this.transition(); // in case user manually called transition() but forgot to return ASYNC |
141 | | - return StateMachine.SUCCEEDED; |
| 141 | + return this.transition(); // in case user manually called transition() but forgot to return ASYNC |
142 | 142 | } |
143 | 143 |
|
144 | 144 | }; |
|
0 commit comments