NAME

org::puremvc::perl5::patterns::command::MacroCommand

inherits:

A Base pureMVC Command concept implementation that executes other commands.


SYNOPSIS

  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;


DESCRIPTION

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.


INTERFACE

Methods

initializeMacroCommand

sub initializeMacroCommand();

Initialize the MacroCommand.

In your subclass, override this method to register the MacroCommand's SubCommands like this:

  $self->addSubCommand( "com::me::myapp::commands::ASubCommand" );
addSubCommand

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

execute

sub execute( $notification );

Execute the MacroCommand's SubCommands.

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

Parameters

Properties

_subcommands

Array reference on registered SubCommands with the MacroCommand. You should not have to access it and must not update it in normal usage.


SEE ALSO

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

org::puremvc::perl5::patterns::observer::Notifier

org::puremvc::perl5::patterns::observer::Observer