new MacroCommand()
A base Command
implementation that executes other Command
s.
A `MacroCommand` maintains a list of `Command` Class references called SubCommands.
When `execute` is called, the `MacroCommand` instantiates and calls `execute` on each of its SubCommands turn. Each SubCommand will be passed a reference to the original `Notification` that was passed to the `MacroCommand`'s `execute` method.
Unlike `SimpleCommand`, your subclass should not override `execute`, but instead, should override the `initializeMacroCommand` method, calling `addSubCommand` once for each SubCommand to be executed.
- Source:
- See:
-
- Controller Controller
- Notification Notification
- SimpleCommand SimpleCommand
Members
(protected) subCommands :Array.<function(): SimpleCommand>
- Source:
Type:
-
Array.<function(): SimpleCommand>
Methods
addSubCommand(factory)
Add a SubCommand.
The SubCommands will be called in First In/First Out (FIFO) order.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
factory |
function
|
execute(notification)
Execute this MacroCommand
's SubCommands.
The SubCommands will be called in First In/First Out (FIFO) order.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
notification |
Notification
|
initializeMacroCommand()
Initialize the MacroCommand
.
In your subclass, override this method to initialize the `MacroCommand`'s SubCommand list with `Command` class references like this:
` // Initialize MyMacroCommand initializeMacroCommand() { this.addSubCommand(() => new app.FirstCommand()); this.addSubCommand(() => new app.SecondCommand()); this.addSubCommand(() => new app.ThirdCommand()); } `
Note that SubCommands may be any `Command` implementor, `MacroCommand`s or `SimpleCommands` are both acceptable.
- Source: