Futurescale, Inc. PureMVC Home

The PureMVC Framework Code at the Speed of Thought


Over 10 years of community discussion and knowledge are maintained here as a read-only archive.

New discussions should be taken up in issues on the appropriate projects at https://github.com/PureMVC

Pages: 1 [2]
Print
Author Topic: How to properly manage application states  (Read 17929 times)
Neil Manuell
Courseware Beta
Sr. Member
***
Posts: 109


View Profile Email
« Reply #15 on: January 14, 2009, 01:39:00 »

sorry, didn't see this thread...

@cliff - ok by me to remove the entry into same state... I think I was even harder and threw an error.

as for AsynchCommand, I did this demo http://revisual.co.uk/?p=409 and failed to get it to hold the thread, so I don't think that is a so;ution here, though I may have done it wrong.

I can see this Asynch incompatibility with the Statemachine as being a problem for some people, though I myself haven't yet come across a way of organising the states that can't overcome this.

@sinosoidal what I have done in the past is to sendNotification(CHANGE_STATE_REQUEST, null, ACTION_NAME), which will trigger a Command that pops the alert, or does what ever checking is necessary.  If all conditions are met, a sendNotification(StateMachine.ACTION, null, ACTION_NAME) is triggered, otherwise nothing.

hope this helps
Logged
sinosoidal
Jr. Member
**
Posts: 15


View Profile Email
« Reply #16 on: January 14, 2009, 02:07:28 »

Hi,

I really had to resolve this question afternoon while I didn't a reply from you. So what i did was to create an intermediate state to hold until the user input.

Its is not a clean solution but it works.

If you guys have a cleaner solution please tell me.

Thanks,

Nuno
Logged
sinosoidal
Jr. Member
**
Posts: 15


View Profile Email
« Reply #17 on: January 14, 2009, 07:51:17 »

Well I changed the StateMachine in a way that the exiting notification has a type that corresponds to the action (the action that caused state change). The command/mediator that listens to that (state exiting) notification can hold the action and launch it later.

Also, the state entering notification has the currentState as the body, instead the nextState, and also the action.

This way each state entering/exiting notification knows which action caused the state change.

These are little changes that I think you should consider adding to the framework.

Regards,
Nuno
Logged
Neil Manuell
Courseware Beta
Sr. Member
***
Posts: 109


View Profile Email
« Reply #18 on: January 15, 2009, 02:45:04 »

@cliff - is this where we should look into implementing conditionals into the FSM?
Logged
puremvc
Global Moderator
Hero Member
*****
Posts: 2871



View Profile WWW Email
« Reply #19 on: January 16, 2009, 07:36:52 »

It shouldn't fall through if the Command is executed as the sub of an AsyncMacroCommand because its execute can't complete until it has executed all its sub commands and they have called their commandComplete method.
If calling commandComplete is causing an error, perhaps it is not being set properly.

I'll do some tests with StateMachine and AsyncMacroCommand soon and get to the bottom of this. Until then, please study and run the debugger on the Sequential demo to be sure you're following the way AsyncCommand works.

There may be something I'm missing, but I think it should work if implemented properly.

-=Cliff>
Logged
Pages: 1 [2]
Print