puremvc
|
|
« Reply #1 on: February 07, 2010, 10:25:21 » |
|
Currently there is only one way, and that is to define it in all the states that use it. I agree it would be useful to have another way of handling 'global' transitions.
From the standpoint of the utility, there are two ways I can think of at the moment for dealing with it.
1) We could modify the StateMachine itself, adding some new logic and/or action type. 2) We could modify the FSMInjector and the FSM xml schema.
I think the latter might be the best way of handling it. No reason to monkey with what works in the StateMachine itself. Instead, if we had a way of expressing to the FSMInjector 'by the way, put *this* transition inside every state' we'd be duplicating what we can already do manually but consider laborious.
So an FSM definition might look like:
var fsm:XML = <fsm initial={FSMConstants.STARTING}> <!-- GLOBAL TRANSITIONS (added to every state) --> <global> <transition action={FSMConstants.FAILED} target={FSMConstants.FAILING}/> </global>
<!-- STARTUP THE SHELL --> <state name={FSMConstants.STARTING}>
<transition action={FSMConstants.STARTED} target={FSMConstants.PLUMBING}/> </state> <!-- PLUMB THE CORES --> <state name={FSMConstants.PLUMBING} changed={FSMConstants.PLUMB}>
<transition action={FSMConstants.PLUMBED} target={FSMConstants.CONFIGURING}/> </state>
<!-- RETRIEVE, DISTRIBUTE and PARSE CONFIGURATION --> <state name={FSMConstants.CONFIGURING} changed={FSMConstants.CONFIGURE}>
<transition action={FSMConstants.CONFIGURED} target={FSMConstants.ASSEMBLING}/> </state> <!-- ASSEMBLE THE VIEW --> <state name={FSMConstants.ASSEMBLING} changed={FSMConstants.ASSEMBLE}>
<transition action={ShellFacade.ASSEMBLED} target={FSMConstants.NAVIGATING}/> </state>
<!-- READY TO ACCEPT BROWSER OR USER NAVIGATION --> <state name={FSMConstants.NAVIGATING} changed={FSMConstants.NAVIGATE}/> <!-- REPORT FAILURE FROM ANY STATE --> <state name={FSMConstants.FAILING} changed={FSMConstants.FAIL}/>
</fsm>;
Will put this on the todo list. Or Neil, if you have the time, and would like to take a crack at it?
-=Cliff>
|