Constructor.
This Controller
implementation is a Singleton,
so you should not call the constructor
directly, but instead call the static Singleton Factory method,
Controller.getInstance()
Protected
commandMapping of Notification names to Command factories
Protected
Optional
viewLocal reference to View
Protected
Static
instanceSingleton instance
Protected
Static
SINGLETON_Message Constants
If a Command
has previously been registered
to handle the given Notification
, then it is executed.
The notification containing the data or command details needed for execution.
Protected
initializeInitialize 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 View implementation
initializeController() {
this.view = MyView.getInstance(() => new View());
}
Register a particular Command
class as the handler
for a particular Notification
.
If an Command
has already been registered to
handle Notification
s with this name, it is no longer
used, the new Command
is used instead.
The Observer for the new Command is only created if this the first time a Command has been registered for this Notification name.
Static
getController
Singleton Factory method.
A factory function that creates a new instance of the controller if one does not already exist.
the Singleton instance of Controller
.
A Singleton
Controller
implementation.In PureMVC, the
Controller
class follows the 'Command and Controller' strategy, and assumes these responsibilities:Command
s are intended to handle whichNotifications
.Observer
with theView
for eachNotification
that it has aCommand
mapping for.Command
to handle a givenNotification
when notified by theView
.Command
'sexecute
method, passing in theNotification
.Your application must register
Commands
with the Controller.The simplest way is to subclass
Facade
, and use itsinitializeController
method to add your registrations.See
Controller