Classe EventManager
Object
|
+--EventManager
- class
EventManager
the class «EventManager» is the class to manage components events.

the static method subscribe subscribe a callback and a component to an event.
the static method unsubscribe unsubscribe a callback to an event.
the static method fire fires the event called 'eventName'
Remarks :
- Component should have a unique id generated in the constructor and its getter getComponentId otherwise an
UUID will be automatically generated and set in the UUID property of the component
- The DOM container must be overloaded with the method getComponent which must return the component javascript object
-
ex:
var ComponentA = function(domContainer){
var _domElement = document.getElementById(domContainer);
// private function used to set the component reference into its dom element
var _setComponentReference = function(obj){
_domElement.getComponent = function(){ return obj; };
};
_setComponentReference(this); // set the reference
.......... // initializations and declarations
this.doValidate = function(param1, param2){ ... }; // A simple callback
EventManager.subscribe(this, 'onValidate', this.doValidate); // subscribe the doValidate callback to the 'onValidate' event
};
Html code for a descandant node of the ComponentA's DOM container
......
<input type="button" value="Valider" onclick="EventManager.fire(this, 'validate', ["param1_Value", "param2_Value"]);" />
......
Version: 2.8.0
Date: 18/02/2008
Definie dans technique/fw_eventManager.js
Sommaire des Attributs |
<private> Function[][][] |
_registered
Private attribute « _registered » - Array of registered events callbacks
|
Sommaire des Constructeurs |
EventManager
()
Allow the management and linking between component events and dom events
|
Sommaire des Méthodes |
void
|
fire(<DOMElement_Obligatoire> domElement, <String_Obligatoire> eventName, <Array_Optionnel> params)
The public method « fire() » is used to launch a pre-registered component's event
|
void
|
subscribe(<Component_Obligatoire> component, <String_Obligatoire> eventName, <Function_Obligatoire> callback)
The public method « subscribe() » is used to register an event from a component
|
void
|
unsubscribe(<Component_Obligatoire> component, <String_Obligatoire> eventName, <Function_Obligatoire> callback)
The public method « unsubscribe() » is used to unregister an event from a component
|
_registered
<private> Function[][][] _registered
Private attribute « _registered » - Array of registered events callbacks
EventManager
EventManager()
Allow the management and linking between component events and dom events
Version: 2.8.0
Date: 18/02/2008
fire
void fire(<DOMElement_Obligatoire> domElement, <String_Obligatoire> eventName, <Array_Optionnel> params)
The public method « fire() » is used to launch a pre-registered component's event
Parameters:
domElement - DOMElement_Obligatoire
: the DOM Element source of the event, generally use 'this' (see ex on top)
eventName - String_Obligatoire
: the name of the event -> must not be prefixed by 'on' (see ex on top)
params - Array_Optionnel
: the arguments array which will be transfered to the callback (see ex on top)
Version: 2.8.0
Date: 18/02/2008
subscribe
void subscribe(<Component_Obligatoire> component, <String_Obligatoire> eventName, <Function_Obligatoire> callback)
The public method « subscribe() » is used to register an event from a component
Parameters:
component - Component_Obligatoire
: the component which registers the Event
eventName - String_Obligatoire
: the name of the event -> must be prefixed by 'on'
callback - Function_Obligatoire
: the callback associated with the event (inside the callback the key-word 'this' refers to the Component Object)
Version: 2.8.0
Date: 18/02/2008
unsubscribe
void unsubscribe(<Component_Obligatoire> component, <String_Obligatoire> eventName, <Function_Obligatoire> callback)
The public method « unsubscribe() » is used to unregister an event from a component
Parameters:
component - Component_Obligatoire
: the component which registers the Event
eventName - String_Obligatoire
: the name of the event -> must be prefixed by 'on'
callback - Function_Obligatoire
: the callback associated with the event (inside the callback the key-word 'this' refers to the Component Object)
Version: 2.8.0
Date: 18/02/2008
Version 2.10.0, / Etat : Validé
Cette création est mise à disposition selon le Contrat Paternité - Pas d'Utilisation Commerciale - Partage des Conditions Initiales à l'Identique disponible en ligne http://creativecommons.org/licenses/by-nc-sa/2.0/fr/ ou par courrier postal à Creative Commons, 559 Nathan Abbott Way, Stanford,California 94305, USA.
Documentation generated by
JSDoc on Wed Jan 6 17:05:02 2010