Class Controller
source code
object --+
|
interfaces.IController --+
|
Controller
A Multiton IController
implementation.
In PureMVC, the Controller
class follows the 'Command and
Controller' strategy, and assumes these responsibilities:
Remembering which ICommand
s are intended to handle which
INotifications
.
Registering itself as an IObserver
with the
View
for each INotification
that it has an
ICommand
mapping for.
Creating a new instance of the proper ICommand
to handle
a given INotification
when notified by the
View
.
Calling the 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.
|
|
|
|
|
executeCommand(self,
note)
If an ICommand has previously been registered to handle
a the given INotification , then it is executed. |
source code
|
|
|
registerCommand(self,
notificationName,
commandClassRef)
Register a particular ICommand class as the handler for
a particular INotification . |
source code
|
|
|
|
|
|
Inherited from object :
__delattr__ ,
__format__ ,
__getattribute__ ,
__hash__ ,
__new__ ,
__reduce__ ,
__reduce_ex__ ,
__repr__ ,
__setattr__ ,
__sizeof__ ,
__str__ ,
__subclasshook__
|
|
instanceMap = { }
Multiton error message
|
|
MULTITON_MSG = ' Controller multiton instance for this key is a ...
|
|
view
Mapping of Notification names to Command Classes
|
|
commandMap
The Multiton Key for this Core
|
Inherited from object :
__class__
|
Remove an IController instance
- Parameters:
key - of IController instance to remove
|
Constructor.
This IController 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
Controller.getInstance( multitonKey )
- Raises:
MultitonError - if instance for this Multiton key has already been constructed
- Overrides:
object.__init__
|
Initialize the Multiton Controller instance.
Called automatically by the constructor.
Note that if you are using a subclass of View in your
application, you should <i>also</i> subclass
Controller and override the
initializeController method in the following way:
// ensure that the Controller is talking to my IView implementation
public function initializeController( ) : void
{
view = MyView.getInstance();
}
- Returns:
- void
|
Controller Multiton Factory method.
- Returns:
- the Multiton instance of
Controller
|
registerCommand(self,
notificationName,
commandClassRef)
| source code
|
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.
The Observer for the new ICommand is only created if this the first
time an ICommand has been registered for this Notification name.
- Parameters:
notificationName - the name of the INotification
commandClassRef - the Class of the ICommand
- Overrides:
interfaces.IController.registerCommand
|
Check if a Command is registered for a given Notification
- Parameters:
notificationName - the name of the INotification
- Returns:
- whether a Command is currently registered for the given
notificationName .
- Overrides:
interfaces.IController.hasCommand
|
Remove a previously registered ICommand to
INotification mapping.
- Parameters:
notificationName - the name of the INotification to remove the
ICommand mapping for
- Overrides:
interfaces.IController.removeCommand
|
MULTITON_MSG
- Value:
' Controller multiton instance for this key is already constructed! '
|
|