Namespace mmir.ControllerManager
Defined in: controllerManager.js.
Constructor Attributes | Constructor Name and Description |
---|---|
A class for managing the controllers of the application.
|
Method Attributes | Method Name and Description |
---|---|
getController(ctrlName)
This function gets the controller by name.
|
|
This function returns names of all loaded controllers.
|
|
Get instance of ControllerManager.
|
|
init(callback)
This function must be called before using the mmir.ControllerManager.
|
|
perform(ctrlName, actionName, data)
This function performs an action of a controller.
|
|
performHelper(ctrlName, actionName, data)
This function performs an action of a helper-class for a controller.
|
Namespace Detail
mmir.ControllerManager
A class for managing the controllers of the application.
It's purpose is to load the controllers and their views / partials and provide functions to find controllers or perform actions or helper-actions. This "class" is structured as a singleton - so that only one instance is in use.
It's purpose is to load the controllers and their views / partials and provide functions to find controllers or perform actions or helper-actions. This "class" is structured as a singleton - so that only one instance is in use.
- Requires:
- jQuery.Deferred
Method Detail
{Object}
getController(ctrlName)
This function gets the controller by name.
- Parameters:
- {String} ctrlName
- Name of the controller which should be returned
- Returns:
- {Object} controller if found, null else
{Array}
getControllerNames()
This function returns names of all loaded controllers.
- Returns:
- {Array
} Names of all loaded controllers
getInstance()
Get instance of ControllerManager.
- Deprecated:
-
use directly: instead of
mmir.ControllerManager.getInstance()
usemmir.ControllerManager
NOTE: The ControllerManager must be initialized, before it can be used! (see ControllerManager#init)
{Promise}
init(callback)
This function must be called before using the mmir.ControllerManager. The Initialization process is asynchronous,
because javascript-files must be loaded (the controllers).
To ensure that the ControllerManager is initialized, a callback can be used, or the returned
Promise (e.g. see documentation of jQuery.Deferred) for code, that relies
on the presence of the loaded controllers.
Note:
The callback function should be used for code, that requires the prior loading of the controllers.
The callback mechanism is necessary, because loading the controllers is asynchronous.
If provided, the callback function is invoked with 1 argument, the ControllerManager instance:
The callback mechanism is necessary, because loading the controllers is asynchronous.
If provided, the callback function is invoked with 1 argument, the ControllerManager instance:
callbackFunction(controllerManagerInstance)
//recommended style: require(['controllerManager', ...], function(controllerManager, ...) { controllerManager.init().then(function(theInitializedControllerInstance){ ... }); }) //old style: function afterLoadingControllers(controllerManagerInstance){ var appCtrl = controllerManagerInstance.getController('Application'); //do something... } mmir.ControllerManager.init(afterLoadingControllers);
- Parameters:
- {Function} callback Optional
- OPTIONAL an optional callback that will be triggered after the controllers where loaded
- Returns:
- {Promise} a Deferred.promise that will get fulfilled when controllers are loaded
{Object}
perform(ctrlName, actionName, data)
This function performs an action of a controller.
- Parameters:
- {String} ctrlName
- Name of the controller to which the action belongs
- {String} actionName
- Name of the action that should be performed
- {Object} data
- optional data that can be submitted to the action
- Returns:
- {Object} the return object of the performed action
{Object}
performHelper(ctrlName, actionName, data)
This function performs an action of a helper-class for a controller.
- Parameters:
- {String} ctrlName
- Name of the controller to which the helper action belongs
- {String} actionName
- Name of the action that should be performed by the helper
- {Object} data
- optional data that can be submitted to the action
- Returns:
- {Object} the return object of the performed action