Over 10 years of community discussion and knowledge are maintained here as a read-only archive.
How does a standalone AsyncCommand differ from a SimpleCommand in such a way that would cause you to use it as anything other than a subcommand of an AsyncMacroCommand?
The point is the AsycCommand is absolutely useless in any context other than as a subcommand of an AsyncMacroCommand. Its call for completion is meaningless.
And the danger is that someone thinks that the thread of execution has stopped during the asych activity, which is not the case unless it is a sub of an AsyncMacroCommand. In any other setting, the thread of execution keeps right on truckin'.
Btw, I am not the author of this utility, that is Duncan Hall. You may wish to take up the question with him.
If it is not a subcommand of an AsyncMacroCommand, its like the sound of one hand clapping. It signifies nothing. No one is listening.
the AsyncCommand and further processing will be suspended until I call commandComplete, which actually does NOTHING at all without the AsyncMacroCommand.
Personally, I rarely do service interaction in commands (Cairngorm style). Since most service interactions end up pulling data into the client that will be used for display and or update back to the server, a long lived entity is more appropriate, which is why the best practices doc suggests use of proxy or proxy/delegate as the preferred method of handling services.
Handling that sort of multistep process where each step could fail and needs to be addressed before the train moves to the next stop a big ugly bear that just crawled from a foul smelling swamp if you approach it with a linear 'chained command' approach.
So, when you finally call commandComplete on an AsyncCommand, what exactly is it that you wish to happen? If it is not a subcommand of an AsyncMacroCommand, its like the sound of one hand clapping. It signifies nothing. No one is listening.
When you invoke the Proxy method to make the remote call, pass a Function typed reference[...]
As for the thread of execution, if an AsyncMacroCommand is running, the thread is running, but in a loop in the AsyncMacro which is waiting for the subcommand to report completion. If you don't have the macro running then your thread moves on. So someone might think well I can just use the AsyncCommand and further processing will be suspended until I call commandComplete, which actually does NOTHING at all without the AsyncMacroCommand.
private function nextCommand () : void { if (subCommands.length > 0) { var commandClassRef:Class = subCommands.shift(); var commandInstance:Object = new commandClassRef(); var isAsync:Boolean = commandInstance is IAsyncCommand; if (isAsync) IAsyncCommand( commandInstance ).setOnComplete( nextCommand ); ICommand( commandInstance ).execute( note ); if (!isAsync) nextCommand(); } else { if(onComplete != null) onComplete(); note = null; onComplete = null; } }
if (!isAsync) nextCommand();
if(onComplete != null) onComplete();
The project page for each utility has a link to the author's page, which has their email address, so if you'd like to talk to Duncan about making this change, just send him an email.
Since most service interactions end up pulling data into the client that will be used for display and or update back to the server, a long lived entity is more appropriate, which is why the best practices doc suggests use of proxy or proxy/delegate as the preferred method of handling services.