This class is the communication bridge between classes.
Each Connector is created to monitor changes in specific properties.
This class can have multiples Listeners registered for that particular
change and can be fired by different objects when this change occurs.
| private | String | eventName | |
| private | String | callBackFunction | |
| private | Array | listeners |
Connector(name:String) |
| public | fireEvent(event) | ||
| public | addListener(target:Object, callBack:String) | ||
| public | removeListener(lis:Object) |
private eventName:String
A String that is usually the same as the variable name of the Connector instance
For example: if we have a Connector name such as "totalLabor", the eventName is "totalLabor".
This String is also used to create a callBackFunction if it is not defined
private callBackFunction:String
A String that represents the function of the Listener to be called when a change occurs
private listeners:Array
A list of all the listeners registered to this Connector
Connector(name:String)
Globals: instantiates the following globals: eventName, callBackFunction, listeners
- Parameters
name (String)-
public fireEvent(event):Void
Description: Goes through the list of listeners and calls the callBack function of each listener.
Assumptions: none
Globals: Uses listeners
Calls: The callBack function in each Listener
Is Called by: Any component that needs to fire an Event
- Parameters
event -- Returns
- Void
public addListener(target:Object,
callBack:String):Boolean
Description: Add a Listener to the list only if this listener has been implemented the callBack function.
Assumptions: listeners and callBackFunction are already instantiated
Globals: Use the following globals: listeners and callBackFunction
Calls: none
Is Called by: Any component that want to register for this event
- Parameters
target (Object)-callBack (String)- (not required)- Returns
- Boolean @throws: An Error if callBack is not implemented
public removeListener(lis:Object):Void
Description: Removes a Listener from the list
Assumptions: Listeners are already instantiated
Globals: Uses listeners
Calls: none
Is Called by: This function is not used by anyone but it's nice to have in case we need.
- Parameters
- Returns
- none