com.triomotor

Connector

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.

Property Summary

private StringeventName
private StringcallBackFunction
private Arraylisteners

Constructor Summary

Connector(name:String)

Method Summary

public fireEvent(event)
public addListener(target:Object, callBack:String)
public removeListener(lis:Object)

Property Details

eventName

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

callBackFunction

private callBackFunction:String

A String that represents the function of the Listener to be called when a change occurs

listeners

private listeners:Array

A list of all the listeners registered to this Connector

Constructor Details

Connector

Connector(name:String)

Globals: instantiates the following globals: eventName, callBackFunction, listeners

Parameters
name (String) -

Method Details

fireEvent

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

addListener

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

removeListener

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