Skip to content

@orillusion/core


Class: CEventDispatcher

Defined in: src/event/CEventDispatcher.ts:10

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

Extended by

Constructors

Constructor

new CEventDispatcher(): CEventDispatcher

Returns

CEventDispatcher

Methods

dispatchEvent()

dispatchEvent(event): void

Defined in: src/event/CEventDispatcher.ts:24

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

Parameters

event

CEvent

Returns

void


destroy()

destroy(): void

Defined in: src/event/CEventDispatcher.ts:54

release all registered event.

Returns

void


addEventListener()

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

Defined in: src/event/CEventDispatcher.ts:78

register an event listener to event distancher.

Parameters

type

string | number

{string} event type.

callback

Function

{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.

thisObject

any

{any} Current registration object, it'll call callback function.

param?

any = null

{any} the data binded to registered event, the default value is null.

priority?

number = 0

{number} The priority of callback function execution, with a larger set value having priority to call

Returns

number

Returns register event id


removeEventListener()

removeEventListener(type, callback, thisObject): void

Defined in: src/event/CEventDispatcher.ts:112

Remove Event Listening

Parameters

type

string | number

{string} event type

callback

Function

{Function} callback function of event register

thisObject

any

{any} The current registered object.

Returns

void


removeEventListenerAt()

removeEventListenerAt(id): boolean

Defined in: src/event/CEventDispatcher.ts:132

Remove an event Listening with id

Parameters

id

number

Returns

boolean


removeAllEventListener()

removeAllEventListener(eventType?): void

Defined in: src/event/CEventDispatcher.ts:152

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

Parameters

eventType?

string | number

Returns

void


containEventListener()

containEventListener(type): boolean

Defined in: src/event/CEventDispatcher.ts:184

whether the target presence of a listener with event type.

Parameters

type

string

{string} event type.

Returns

boolean

Returns a boolean.


hasEventListener()

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

Defined in: src/event/CEventDispatcher.ts:197

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

Parameters

type

string | number

{string} event name.

callback?

Function = null

{Function} callback function of event register.

thisObject?

any = null

{any} The registered object.

Returns

boolean

Returns a boolean.