Packageorg.puremvc.as3.multicore.patterns.facade
Classpublic class Facade
ImplementsIFacade

A base Multiton IFacade implementation.

See also

Model
View
Controller


Protected Properties
 PropertyDefined by
  controller : IController
Facade
  instanceMap : Array
[static]
Facade
  model : IModel
Facade
  multitonKey : String
Facade
  view : IView
Facade
Public Methods
 MethodDefined by
  
Facade(key:String)
Constructor.
Facade
  
getInstance(key:String):IFacade
[static] Facade Multiton Factory method
Facade
  
hasCommand(notificationName:String):Boolean
Check if a Command is registered for a given Notification
Facade
  
hasMediator(mediatorName:String):Boolean
Check if a Mediator is registered or not
Facade
  
hasProxy(proxyName:String):Boolean
Check if a Proxy is registered
Facade
  
initializeNotifier(key:String):void
Set the Multiton key for this facade instance.
Facade
  
notifyObservers(notification:INotification):void
Notify Observers.
Facade
  
registerCommand(notificationName:String, commandClassRef:Class):void
Register an ICommand with the Controller by Notification name.
Facade
  
registerMediator(mediator:IMediator):void
Register a IMediator with the View.
Facade
  
registerProxy(proxy:IProxy):void
Register an IProxy with the Model by name.
Facade
  
removeCommand(notificationName:String):void
Remove a previously registered ICommand to INotification mapping from the Controller.
Facade
  
removeCore(key:String):void
Remove a Core
Facade
  
removeMediator(mediatorName:String):IMediator
Remove an IMediator from the View.
Facade
  
removeProxy(proxyName:String):IProxy
Remove an IProxy from the Model by name.
Facade
  
retrieveMediator(mediatorName:String):IMediator
Retrieve an IMediator from the View.
Facade
  
retrieveProxy(proxyName:String):IProxy
Retrieve an IProxy from the Model by name.
Facade
  
sendNotification(notificationName:String, body:Object = null, type:String = null):void
Create and send an INotification.
Facade
Protected Methods
 MethodDefined by
  
Initialize the Controller.
Facade
  
Initialize the Multiton Facade instance.
Facade
  
Initialize the Model.
Facade
  
Initialize the View.
Facade
Protected Constants
 ConstantDefined by
  MULTITON_MSG : String = "Facade instance for this Multiton key already constructed!"
Facade
Property detail
controllerproperty
protected var controller:IController
instanceMapproperty 
protected static var instanceMap:Array
modelproperty 
protected var model:IModel
multitonKeyproperty 
protected var multitonKey:String
viewproperty 
protected var view:IView
Constructor detail
Facade()constructor
public function Facade(key:String)

Constructor.

This IFacade implementation is a Multiton, so you should not call the constructor directly, but instead call the static Factory method, passing the unique key for this instance Facade.getInstance( multitonKey )

Parameters
key:String

Throws
— Error if instance for this Multiton key has already been constructed
Method detail
getInstance()method
public static function getInstance(key:String):IFacade

Facade Multiton Factory method

Parameters
key:String

Returns
IFacade — the Multiton instance of the Facade
hasCommand()method 
public function hasCommand(notificationName:String):Boolean

Check if a Command is registered for a given Notification

Parameters
notificationName:String

Returns
Boolean — whether a Command is currently registered for the given notificationName.
hasMediator()method 
public function hasMediator(mediatorName:String):Boolean

Check if a Mediator is registered or not

Parameters
mediatorName:String

Returns
Boolean — whether a Mediator is registered with the given mediatorName.
hasProxy()method 
public function hasProxy(proxyName:String):Boolean

Check if a Proxy is registered

Parameters
proxyName:String

Returns
Boolean — whether a Proxy is currently registered with the given proxyName.
initializeController()method 
protected function initializeController():void

Initialize the Controller.

Called by the initializeFacade method. Override this method in your subclass of Facade if one or both of the following are true:

If you don't want to initialize a different IController, call super.initializeController() at the beginning of your method, then register Commands.

initializeFacade()method 
protected function initializeFacade():void

Initialize the Multiton Facade instance.

Called automatically by the constructor. Override in your subclass to do any subclass specific initializations. Be sure to call super.initializeFacade(), though.

initializeModel()method 
protected function initializeModel():void

Initialize the Model.

Called by the initializeFacade method. Override this method in your subclass of Facade if one or both of the following are true:

If you don't want to initialize a different IModel, call super.initializeModel() at the beginning of your method, then register Proxys.

Note: This method is rarely overridden; in practice you are more likely to use a Command to create and register Proxys with the Model, since Proxys with mutable data will likely need to send INotifications and thus will likely want to fetch a reference to the Facade during their construction.

initializeNotifier()method 
public function initializeNotifier(key:String):void

Set the Multiton key for this facade instance.

Not called directly, but instead from the constructor when getInstance is invoked. It is necessary to be public in order to implement INotifier.

Parameters
key:String
initializeView()method 
protected function initializeView():void

Initialize the View.

Called by the initializeFacade method. Override this method in your subclass of Facade if one or both of the following are true:

If you don't want to initialize a different IView, call super.initializeView() at the beginning of your method, then register IMediator instances.

Note: This method is rarely overridden; in practice you are more likely to use a Command to create and register Mediators with the View, since IMediator instances will need to send INotifications and thus will likely want to fetch a reference to the Facade during their construction.

notifyObservers()method 
public function notifyObservers(notification:INotification):void

Notify Observers.

This method is left public mostly for backward compatibility, and to allow you to send custom notification classes using the facade.

P> Usually you should just call sendNotification and pass the parameters, never having to construct the notification yourself.

Parameters
notification:INotification — the INotification to have the View notify Observers of.
registerCommand()method 
public function registerCommand(notificationName:String, commandClassRef:Class):void

Register an ICommand with the Controller by Notification name.

Parameters
notificationName:String — the name of the INotification to associate the ICommand with
 
commandClassRef:Class — a reference to the Class of the ICommand
registerMediator()method 
public function registerMediator(mediator:IMediator):void

Register a IMediator with the View.

Parameters
mediator:IMediator — the name to associate with this IMediator
registerProxy()method 
public function registerProxy(proxy:IProxy):void

Register an IProxy with the Model by name.

Parameters
proxy:IProxy — the name of the IProxy.
removeCommand()method 
public function removeCommand(notificationName:String):void

Remove a previously registered ICommand to INotification mapping from the Controller.

Parameters
notificationName:String — the name of the INotification to remove the ICommand mapping for
removeCore()method 
public function removeCore(key:String):void

Remove a Core

Parameters
key:String — of the Core to remove
removeMediator()method 
public function removeMediator(mediatorName:String):IMediator

Remove an IMediator from the View.

Parameters
mediatorName:String — name of the IMediator to be removed.

Returns
IMediator — the IMediator that was removed from the View
removeProxy()method 
public function removeProxy(proxyName:String):IProxy

Remove an IProxy from the Model by name.

Parameters
proxyName:String — the IProxy to remove from the Model.

Returns
IProxy — the IProxy that was removed from the Model
retrieveMediator()method 
public function retrieveMediator(mediatorName:String):IMediator

Retrieve an IMediator from the View.

Parameters
mediatorName:String

Returns
IMediator — the IMediator previously registered with the given mediatorName.
retrieveProxy()method 
public function retrieveProxy(proxyName:String):IProxy

Retrieve an IProxy from the Model by name.

Parameters
proxyName:String — the name of the proxy to be retrieved.

Returns
IProxy — the IProxy instance previously registered with the given proxyName.
sendNotification()method 
public function sendNotification(notificationName:String, body:Object = null, type:String = null):void

Create and send an INotification.

Keeps us from having to construct new notification instances in our implementation code.

Parameters
notificationName:String — the name of the notiification to send
 
body:Object (default = null) — the body of the notification (optional)
 
type:String (default = null) — the type of the notification (optional)
Constant detail
MULTITON_MSGconstant
protected const MULTITON_MSG:String = "Facade instance for this Multiton key already constructed!"