org::puremvc::perl5::patterns::command::MacroCommand
inherits:
A Base pureMVC Command
concept implementation that executes other commands
.
package com::me::myapp::commands::AMacroCommand;
use strict; use warnings;
use org::puremvc::perl5::patterns::command::MacroCommand; our @ISA = qw( org::puremvc::perl5::patterns::command::MacroCommand );
use com::me::myapp::commands::AFirstSubCommand; use com::me::myapp::commands::ASecondSubCommand;
sub initializeMacroCommand { my $self = shift; $self->addSubCommand( "com::me::myapp::commands::AFirstSubCommand" ); $self->addSubCommand( "com::me::myapp::commands::ASecondSubCommand" ); }
#********************** #********************** 1;
A MacroCommand
maintains a list of Commands class names called SubCommands.
When execute
is called, the MacroCommand
instantiates and calls execute
on each of its SubCommands in the order they where registered.
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.
A SubCommand can be a SimpleCommand or another MacroCommand
.
Initialize the MacroCommand
.
In your subclass, override this method to register the MacroCommand's
SubCommands like this:
$self->addSubCommand( "com::me::myapp::commands::ASubCommand" );
sub addSubCommand( $command_class_ref );
Register a SubCommand to the MacroCommand
's list.
The SubCommands will be called in First In/First Out (FIFO) order.
Parameters
$command_class_ref - String
Name of the SubCommand to register to the MacroCommand
's list.
Execute the MacroCommand
's SubCommands.
The SubCommands will be called in First In/First Out (FIFO) order.
Parameters
$notification - org::puremvc::perl5::patterns::observer::Notification
The notification to handle by each MacroCommand
's SubCommand.
Array reference on registered SubCommands with the MacroCommand
. You should not have to access it and must not update it in normal usage.
org::puremvc::perl5::core::Model
org::puremvc::perl5::core::View
org::puremvc::perl5::core::Controller
org::puremvc::perl5::patterns::facade::Facade
org::puremvc::perl5::patterns::observer::Notification
org::puremvc::perl5::patterns::proxy::Proxy
org::puremvc::perl5::patterns::mediator::Mediator
org::puremvc::perl5::patterns::command::SimpleCommand