Home Reference Source Test
public class | source

CallbackRegistry

Generic class to manage a list of callbacks.

Constructor Summary

Public Constructor
public

constructor(wrapper: Function)

Creates a new list of callbacks.

Member Summary

Public Members
public
public

wrapper: *

Method Summary

Public Methods
public

add(callback: Function, context: Object, trace: Error): Function

Registers a new callback.

public

call(entry: Object, args: Array)

Executes the given callback passing arguments.

public

clear()

Removes all registered callbacks.

public

Returns the number of registered callbacks.

public

indexOf(callback: Function): Number

Finds the given callback within the list.

public

remove(callback: Function): Boolean

Removes the given callback from the registry.

public

run()

Executes all registered callbacks passing given arguments.

Public Constructors

public constructor(wrapper: Function) source

Creates a new list of callbacks.

Params:

NameTypeAttributeDescription
wrapper Function

used to wrap non-function callbacks into function

Public Members

public callbacks: * source

public wrapper: * source

Public Methods

public add(callback: Function, context: Object, trace: Error): Function source

Registers a new callback. Call the wrapper passed on contructur if the argument is not a function. Throws an exception if the callback is already registered.

Params:

NameTypeAttributeDescription
callback Function

to be registered

context Object

this variable for the callback

trace Error

error for tracing purposes

Return:

Function

wrappedCallback

public call(entry: Object, args: Array) source

Executes the given callback passing arguments.

Params:

NameTypeAttributeDescription
entry Object
args Array

public clear() source

Removes all registered callbacks.

public count(): Number source

Returns the number of registered callbacks.

Return:

Number

count

public indexOf(callback: Function): Number source

Finds the given callback within the list.

Params:

NameTypeAttributeDescription
callback Function

to be found

Return:

Number

index of the callback within the list

public remove(callback: Function): Boolean source

Removes the given callback from the registry.

Params:

NameTypeAttributeDescription
callback Function

to be removed

Return:

Boolean

removed true if the callback was found

public run() source

Executes all registered callbacks passing given arguments.