AsyncMacroCommand
A base ICommand
implementation that executes other
ICommand
s asynchronously.
An AsyncMacroCommand
maintains a list of
closures returning ICommand
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 org.puremvc.as3.multicore.patterns.command.AsyncCommand AsyncCommand
-
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()
.Declaration
Swift
public override init()
-
Initialize the
AsyncMacroCommand
.In your subclass, override this method to initialize the
AsyncMacroCommand
’s SubCommand list withICommand
class references.// Initialize MyMacroCommand override public func initializeAsyncMacroCommand() { addSubCommand( { FirstCommand() } ) addSubCommand( { SecondCommand() } ) addSubCommand { ThirdCommand() } //trailing closure style }
Note that SubCommands may be any closure returning
ICommand
implementor,AsyncMacroCommand
s,AsyncCommand
s,MacroCommand
s orSimpleCommand
s are all acceptable.Declaration
Swift
public func initializeAsyncMacroCommand() {}
-
Add a SubCommand.
The SubCommands will be called in First In/First Out (FIFO) order.
Declaration
Swift
public func addSubCommand(closure: () -> ICommand)
Parameters
closure
reference returning
ICommand
. -
Starts execution of this
AsyncMacroCommand
’s SubCommands.The SubCommands will be called in First In/First Out (FIFO) order.
Declaration
Swift
public final func execute(notification: INotification)
Parameters
notification
the
INotification
object to be passsed to each SubCommand. -
Get or set the callback for a parent
AsyncMacroCommand
.Declaration
Swift
public var onComplete: (() -> ())?