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()
ProtectedcommandMapping of Notification names to Command factories
Protected OptionalviewLocal reference to View
Protected StaticinstanceSingleton instance
Protected StaticSINGLETON_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.
ProtectedinitializeInitialize 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 Notifications 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.
StaticgetController 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
Controllerimplementation.In PureMVC, the
Controllerclass follows the 'Command and Controller' strategy, and assumes these responsibilities:Commands are intended to handle whichNotifications.Observerwith theViewfor eachNotificationthat it has aCommandmapping for.Commandto handle a givenNotificationwhen notified by theView.Command'sexecutemethod, passing in theNotification.Your application must register
Commandswith the Controller.The simplest way is to subclass
Facade, and use itsinitializeControllermethod to add your registrations.See
Controller