PureMVC Architects Lounge

Announcements and General Discussion => General Discussion => Topic started by: nisimjoseph on September 29, 2008, 05:45:03



Title: How to create sequential (queue) commands ?
Post by: nisimjoseph 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


Title: Re: How to create sequential (queue) commands ?
Post by: puremvc 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> 


Title: Re: How to create sequential (queue) commands ?
Post by: nisimjoseph on September 29, 2008, 07:06:18
ok. i will check it out.
10x on all the help until now.

Nisim


Title: Re: How to create sequential (queue) commands ?
Post by: codecraig 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!


Title: Re: How to create sequential (queue) commands ?
Post by: puremvc 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>