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]
Print
Author Topic: How to create sequential (queue) commands ?  (Read 6708 times)
nisimjoseph
Full Member
***
Posts: 22


View Profile Email
« on: September 29, 2008, 05:45:03 »

i have another question about the architecture.
right now we have the way to get MacroCommand and this will fire all the SimpleCommand's in it as parallel execution and not as Sequential (queue, one over and then the next will fire).
i saw in the forum other question like this but no real answer was done on this.
do we have something to do about it in the PureMVC architecture ?

10x,
Nisim Joseph
Logged
puremvc
Global Moderator
Hero Member
*****
Posts: 2871



View Profile WWW Email
« Reply #1 on: September 29, 2008, 06:33:00 »

Flash is single threaded, so there is no possibility of parallel execution of Commands.

The only thing that might happen is one subcommand might trigger an async process such a service call, and the next subcommand could execute before the service returns. In this case you want another ICommand to respond to a notification from the Proxy when the service returns rather than placing it as the next subcommand in the MacroCommand's list.
There is also a Notification Chaining Utility written by Trilec that can help with this: http://forums.puremvc.org/index.php?topic=422.0

-=Cliff> 
Logged
nisimjoseph
Full Member
***
Posts: 22


View Profile Email
« Reply #2 on: September 29, 2008, 07:06:18 »

ok. i will check it out.
10x on all the help until now.

Nisim
Logged
codecraig
Full Member
***
Posts: 23


View Profile Email
« Reply #3 on: October 02, 2008, 02:59:54 »

I had the same question recently, ultimately I came up with my own MacroCommand.  I can't share the code but essentially it loop through the subcommands and set a "finished" function on the command and then execute the command.  The "finished" function is a way for the command to notify the MacroCommand that it has finished.  Then my MacroCommand basically keeps track of this and knows when to execute the next command.

Works well for me and my many async. requests!
Logged
puremvc
Global Moderator
Hero Member
*****
Posts: 2871



View Profile WWW Email
« Reply #4 on: October 02, 2008, 05:06:49 »

@codecraig

That must mean you are using the Command to make service calls and as responders for those async operations (cairngorm style).

While it will work it is not a best practice. Why?

How do you 'cancel' a service call that's been sent?

You can't. Because you can't get a reference to the Command that's sitting out there waiting for the service to return in order to tell its HTTPService (or RemoteObject or whatever) to cancel its operation.

This is why the Proxy is typically used for service interaction. Or a delegate used by a Proxy if there is more than one Proxy needing the service.

Otherwise all you can do is set a flag somewhere that says if you've cancelled the call and the Command would need to check it when the service result or fault returns.

-=Cliff>
Logged
Pages: [1]
Print