org::puremvc::perl5::core::View
Singleton responsible for implementing the MVC View
pattern.
In PureMVC, the View
class assumes these responsibilities:
Maintain a cache of Mediator instances.
Provide methods for registering, retrieving, and removing mediators.
Notifiying mediators when they are registered or removed.
Managing the observers lists for each notification in the application.
Providing a method for attaching observers to a notification's observer list.
Providing a method for broadcasting a notification.
Notifying the observers of a given notification when it broadcast.
Returns the singleton instance of the View
.
Returns
org::puremvc::perl5::core::View
- The singleton instance of the View
.
Initialize the singleton instance of the View
.
This method is automatically called during singleton instantiation.
This is where you will achieve your View
subclass specific initializations if your application actually overrides pureMVC View
class.
sub registerObserver( $notification_name, $observer );
Register an observer to be notified of notifications with a given name.
Parameters
$notification_name - String
Name of the notifications the registered observer will be notified of.
$observer - org::puremvc::perl5::patterns::observer::Observer
The registered observer with the View
.
sub notifyObservers( $notification );
Notify the observer for a particular notification.
All previously attached observer for this notification's list are notified and are passed a reference to the notification in the order in which they were registered.
Parameters
$notification - org::puremvc::perl5::patterns::observer::Notification
Instance of Notification the observers will receive as a parameter when notified.
sub removeObserver( $notification_name, $observer );
Remove the observer from the observers list for a given notification name.
Parameters
$notification_name - String
Name of the notifications the registered observer will be removed from.
$observer - org::puremvc::perl5::patterns::observer::Observer
The registered observer with the View
to be removed.
sub registerMediator( $mediator );
Register a Mediator instance with the View
. During registration mediator's getMediatorName
method is called by View
singleton to map $mediator
instance with its name.
Any registered mediator is afterwards retrieved, removed or checked by its name.
Registers the mediator so that it can be retrieved by name, and further interrogates the mediator for its notification interests.
If the mediator returns any notification name to be notified about, an observer is created encapsulating the mediator instance's handleNotification
method and registering it as an observer for all notifications the mediator is interested in.
Parameters
$mediator - org::puremvc::perl5::patterns::mediator::Mediator
A Mediator instance to register with the View
.
sub retrieveMediator( $mediator_name );
Retrieve from the View
a mediator registered with name $mediator_name
.
Parameters
$mediator_name - String
Name of the mediator to retrieve from the View
.
Returns
org::puremvc::perl5::patterns::mediator::Mediator
- The Mediator instance retrieved from the View
.
sub removeMediator( $mediator_name );
Remove from the View
a mediator registered with name $mediator_name
.
Parameters
$mediator_name - String
Name of the mediator to remove from the View
.
Returns
org::puremvc::perl5::patterns::mediator::Mediator
- The Mediator instance removed from the View
.
sub hasMediator( $mediator_name );
Check whether a mediator is registered with name $mediator_name
or not.
Parameters
$mediator_name - String
Name of the mediator to check.
Returns
scalar
- 1 if a Mediator instance is registered with the View
with name $mediator_name
, "" otherwise.
Array reference on registered mediators with the View
. You should not have to access it and must not update it in normal usage.
Array reference on registered observers with the View
. You should not have to access it and must not update it in normal usage.
org::puremvc::perl5::core::Model
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::command::MacroCommand