Skip to content

Class: CEventDispatcher

Basic class of event diapatcher. It includes the implementation of functions such as event registration, deregistration, distribution, and unregister.

Hierarchy

Constructors

Methods

Constructors

constructor

new CEventDispatcher(): CEventDispatcher

Returns

CEventDispatcher

Methods

dispatchEvent

dispatchEvent(event): void

Dispatch an event to all registered objects with a specific type of listener.

Parameters

NameType
eventCEvent

Returns

void

Defined in

src/event/CEventDispatcher.ts:24


destroy

destroy(): void

release all registered event.

Returns

void

Defined in

src/event/CEventDispatcher.ts:55


addEventListener

addEventListener(type, callback, thisObject, param?, priority?): number

register an event listener to event distancher.

Parameters

NameTypeDefault valueDescription
typestring | numberundefined{string} event type.
callbackFunctionundefined{Function} The callback function that handles events. This function must accept an Event3D object as its unique parameter and cannot return any result. for example: function(evt:Event3D):void.
thisObjectanyundefined{any} Current registration object, it'll call callback function.
paramanynull{any} the data binded to registered event, the default value is null.
prioritynumber0{number} The priority of callback function execution, with a larger set value having priority to call

Returns

number

Returns register event id

Defined in

src/event/CEventDispatcher.ts:79


removeEventListener

removeEventListener(type, callback, thisObject): void

Remove Event Listening

Parameters

NameTypeDescription
typestring | number{string} event type
callbackFunction{Function} callback function of event register
thisObjectany{any} The current registered object.

Returns

void

Defined in

src/event/CEventDispatcher.ts:113


removeEventListenerAt

removeEventListenerAt(id): boolean

Remove an event Listening with id

Parameters

NameType
idnumber

Returns

boolean

Defined in

src/event/CEventDispatcher.ts:133


removeAllEventListener

removeAllEventListener(eventType?): void

Specify a event type to remove all related event listeners eventType event type, set null to remove all event listeners

Parameters

NameTypeDefault value
eventTypestring | numbernull

Returns

void

Defined in

src/event/CEventDispatcher.ts:153


containEventListener

containEventListener(type): boolean

whether the target presence of a listener with event type.

Parameters

NameTypeDescription
typestring{string} event type.

Returns

boolean

Returns a boolean.

Defined in

src/event/CEventDispatcher.ts:185


hasEventListener

hasEventListener(type, callback?, thisObject?): boolean

whether the target presence of a listener with event type. it associate more registration parameters.

Parameters

NameTypeDefault valueDescription
typestring | numberundefined{string} event name.
callbackFunctionnull{Function} callback function of event register.
thisObjectanynull{any} The registered object.

Returns

boolean

Returns a boolean.

Defined in

src/event/CEventDispatcher.ts:198