Documentation
¶
Index ¶
- func GetInstance(key string, factory func() interfaces.IController) interfaces.IController
- func RemoveController(key string)
- type Controller
- func (self *Controller) ExecuteCommand(notification interfaces.INotification)
- func (self *Controller) HasCommand(notificationName string) bool
- func (self *Controller) InitializeController()
- func (self *Controller) RegisterCommand(notificationName string, factory func() interfaces.ICommand)
- func (self *Controller) RemoveCommand(notificationName string)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetInstance ¶
func GetInstance(key string, factory func() interfaces.IController) interfaces.IController
GetInstance Controller Multiton Factory method.
- parameter key: multitonKey
- parameter factory reference that returns IController
- returns: the Multiton instance
func RemoveController ¶
func RemoveController(key string)
RemoveController Remove an IController instance
- parameter multitonKey: of IController instance to remove
Types ¶
type Controller ¶
type Controller struct {
Key string // The Multiton Key for this Core
// contains filtered or unexported fields
}
Controller A Multiton IController implementation.
In PureMVC, the Controller class follows the 'Command and Controller' strategy, and assumes these responsibilities:
* Remembering which ICommands 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.
func (*Controller) ExecuteCommand ¶
func (self *Controller) ExecuteCommand(notification interfaces.INotification)
ExecuteCommand If an ICommand has previously been registered to handle a the given INotification, then it is executed.
- parameter note: an INotification
func (*Controller) HasCommand ¶
func (self *Controller) HasCommand(notificationName string) bool
HasCommand Check if a Command is registered for a given Notification
- parameter notificationName:
- returns: whether a Command is currently registered for the given notificationName.
func (*Controller) InitializeController ¶
func (self *Controller) InitializeController()
InitializeController Initialize the Singleton Controller instance.
Called automatically by the GetInstance.
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:
func (self *MyController) InitializeController() {
self.commandMap = map[string]func() interfaces.ICommand{}
self.view = MyView.GetInstance(self.Key, func() interfaces.IView { return &MyView{Key: self.Key} })
}
func (*Controller) RegisterCommand ¶
func (self *Controller) RegisterCommand(notificationName string, factory func() interfaces.ICommand)
RegisterCommand Register a particular ICommand class as the handler for a particular INotification.
If an ICommand has already been registered to handle INotifications 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 regisered for this Notification name.
- parameter notificationName: the name of the INotification
- parameter factory: reference that returns ICommand
func (*Controller) RemoveCommand ¶
func (self *Controller) RemoveCommand(notificationName string)
RemoveCommand Remove a previously registered ICommand to INotification mapping.
- parameter notificationName: the name of the INotification to remove the ICommand mapping for