Package | org.puremvc.as3.core |
Class | public class Controller |
Implements | IController |
IController
implementation.
In PureMVC, the Controller
class follows the
'Command and Controller' strategy, and assumes these
responsibilities:
ICommand
s
are intended to handle which INotifications
.IObserver
with
the View
for each INotification
that it has an ICommand
mapping for.ICommand
to handle a given INotification
when notified by the View
.ICommand
's execute
method, passing in the INotification
.
Your application must register ICommands
with the
Controller.
The simplest way is to subclass Facade,
and use its initializeController
method to add your
registrations.
See also
Property | Defined by | ||
---|---|---|---|
commandMap : Array | Controller | ||
instance : IController
[static]
| Controller | ||
view : IView | Controller |
Method | Defined by | ||
---|---|---|---|
Constructor.
| Controller | ||
executeCommand(note:INotification):void
If an
ICommand has previously been registered
to handle a the given INotification , then it is executed. | Controller | ||
[static]
Controller Singleton Factory method. | Controller | ||
hasCommand(notificationName:String):Boolean
Check if a Command is registered for a given Notification
| Controller | ||
registerCommand(notificationName:String, commandClassRef:Class):void
Register a particular
ICommand class as the handler
for a particular INotification . | Controller | ||
removeCommand(notificationName:String):void
Remove a previously registered
ICommand to INotification mapping. | Controller |
Method | Defined by | ||
---|---|---|---|
initializeController():void
Initialize the Singleton
Controller instance. | Controller |
Constant | Defined by | ||
---|---|---|---|
SINGLETON_MSG : String = "Controller Singleton already constructed!" | Controller |
commandMap | property |
protected var commandMap:Array
instance | property |
protected static var instance:IController
view | property |
protected var view:IView
Controller | () | constructor |
public function Controller()
Constructor.
This IController
implementation is a Singleton,
so you should not call the constructor
directly, but instead call the static Singleton
Factory method Controller.getInstance()
— Error if Singleton instance has already been constructed
|
executeCommand | () | method |
public function executeCommand(note:INotification):void
If an ICommand
has previously been registered
to handle a the given INotification
, then it is executed.
note:INotification — an INotification
|
getInstance | () | method |
public static function getInstance():IController
Controller
Singleton Factory method.
IController —
the Singleton instance of Controller
|
hasCommand | () | method |
public function hasCommand(notificationName:String):Boolean
Check if a Command is registered for a given Notification
ParametersnotificationName:String |
Boolean — whether a Command is currently registered for the given notificationName .
|
initializeController | () | method |
protected function initializeController():void
Initialize the Singleton Controller
instance.
Called automatically by the constructor.
Note that if you are using a subclass of View
in your application, you should also subclass Controller
and override the initializeController
method in the
following way:
// ensure that the Controller is talking to my IView implementation override public function initializeController( ) : void { view = MyView.getInstance(); }
registerCommand | () | method |
public function registerCommand(notificationName:String, commandClassRef:Class):void
Register a particular ICommand
class as the handler
for a particular INotification
.
If an ICommand
has already been registered to
handle INotification
s with this name, it is no longer
used, the new ICommand
is used instead.
notificationName:String — the name of the INotification
|
|
commandClassRef:Class — the Class of the ICommand
|
removeCommand | () | method |
public function removeCommand(notificationName:String):void
Remove a previously registered ICommand
to INotification
mapping.
notificationName:String — the name of the INotification to remove the ICommand mapping for
|
SINGLETON_MSG | constant |
protected const SINGLETON_MSG:String = "Controller Singleton already constructed!"