Packageorg.puremvc.as3.patterns.command
Classpublic class AsyncMacroCommand
InheritanceAsyncMacroCommand Inheritance org.puremvc.as3.patterns.observer.Notifier
ImplementsIAsyncCommand, org.puremvc.as3.interfaces.INotifier

A base ICommand implementation that executes other ICommands asynchronously.

An AsyncMacroCommand maintains a list of ICommand Class references called SubCommands.

When execute is called, the AsyncMacroCommand caches a reference to the INotification and calls nextCommand.

If there are still SubCommands's to be executed, the nextCommand method instantiates and calls execute on each of its SubCommands in turn. Each SubCommand will be passed a reference to the original INotification that was passed to the AsyncMacroCommand's execute method. If the SubCommand to execute is an IAsyncCommand, the next SubCommand will not be executed until the previous IAsyncCommand has called its commandComplete method.

Unlike AsyncCommand and SimpleCommand, your subclass should not override execute, but instead, should override the initializeAsyncMacroCommand method, calling addSubCommand once for each SubCommand to be executed.

See also

AsyncCommand


Public Methods
 MethodDefined by
  
Constructor.
AsyncMacroCommand
  
execute(notification:INotification):void
Starts execution of this AsyncMacroCommand's SubCommands.
AsyncMacroCommand
  
setOnComplete(value:Function):void
Registers the callback for a parent AsyncMacroCommand.
AsyncMacroCommand
Protected Methods
 MethodDefined by
  
addSubCommand(commandClassRef:Class):void
Add a SubCommand.
AsyncMacroCommand
  
Initialize the AsyncMacroCommand.
AsyncMacroCommand
Constructor detail
AsyncMacroCommand()constructor
public function AsyncMacroCommand()

Constructor.

You should not need to define a constructor, instead, override the initializeAsyncMacroCommand method.

If your subclass does define a constructor, be sure to call super().

Method detail
addSubCommand()method
protected function addSubCommand(commandClassRef:Class):void

Add a SubCommand.

The SubCommands will be called in First In/First Out (FIFO) order.

Parameters
commandClassRef:Class — a reference to the Class of the ICommand.
execute()method 
public final function execute(notification:INotification):void

Starts execution of this AsyncMacroCommand's SubCommands.

The SubCommands will be called in First In/First Out (FIFO) order.

Parameters
notification:INotification — the INotification object to be passsed to each SubCommand.
initializeAsyncMacroCommand()method 
protected function initializeAsyncMacroCommand():void

Initialize the AsyncMacroCommand.

In your subclass, override this method to initialize the AsyncMacroCommand's SubCommand list with ICommand class references.

    // Initialize MyMacroCommand
    override protected function initializeAsyncMacroCommand() : void
    {
     addSubCommand( com.me.myapp.controller.FirstCommand );
     addSubCommand( com.me.myapp.controller.SecondCommand );
     addSubCommand( com.me.myapp.controller.ThirdCommand );
    }
   

Note that SubCommands may be any ICommand implementor, AsyncMacroCommands, AsyncCommands, MacroCommands or SimpleCommands are all acceptable.

setOnComplete()method 
public function setOnComplete(value:Function):void

Registers the callback for a parent AsyncMacroCommand.

Parameters
value:Function — The AsyncMacroCommand method to call on completion