Constructor.
You should not need to define a constructor,
instead, override the initializeMacroCommand
method.
If your subclass does define a constructor, be
sure to call super()
.
Protected
addExecute this MacroCommand
's SubCommands
.
The SubCommands
will be called in First In/First Out (FIFO)
order.
The notification containing the data or command details to be processed.
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 SubCommand
s may be any Command
implementor,
MacroCommand
s or SimpleCommands
are both acceptable.
Create and send an Notification
.
Keeps us from having to construct new Notification instances in our implementation code.
The name of the notification to be sent.
Optional
body: anyOptional data to be included with the notification.
Optional
type: stringOptional type of the notification.
A base
Command
implementation that executes otherCommand
s.A
MacroCommand
maintains a list ofCommand
Class references calledSubCommands
.When
execute
is called, theMacroCommand
instantiates and callsexecute
on each of itsSubCommands
turn. EachSubCommand
will be passed a reference to the originalNotification
that was passed to theMacroCommand
'sexecute
method.Unlike
SimpleCommand
, your subclass should not overrideexecute
, but instead, should override theinitializeMacroCommand
method, callingaddSubCommand
once for eachSubCommand
to be executed.See
MacroCommand