Skip to main content

IEventEmitter

TypeNameInterface Description
Functionson(eventType: number, callback: (event: IEvent) => void, context?: object): void

Parameters

• eventType: number

The type of event to listen for, which can be either a number or a predefined UserEventType.

• callback: (event: IEvent) => void

A function that will be executed when the event occurs. This function receives an IEvent object as its parameter.

• OptionalContext: object

(Optional) The execution context in which the callback function should be called.

Returns void

Description

Register an event listener for a specified event type, invoking the provided callback function when the event is triggered.

Functionsonce(eventType: number, callback: (event: IEvent) => void, context?: object): void

Parameters

• eventType: number

The type of event to listen for. Can be either a number or a UserEventType enum value.

• callback: (event: IEvent) => void

The function to execute when the event is triggered. It takes an IEvent object as its parameter.

• OptionalContext: object

Optional: The context in which the callback will be executed. This can be used to maintain 'this' reference inside the callback.

Returns void

Description

Register a callback that will be executed only once for the specified event type.

Functionsoff(eventType: number, callback: (event: IEvent) => void, context?: object): void

Parameters

• eventType: number

The type of event to unregister. Can be a number or a UserEventType enum value.

• callback: (event: IEvent) => void

The callback function that was previously registered to handle the event.

• OptionalContext: object

Optional: The context object that was used when registering the callback.

Returns void

Description

Unregister an event callback from the object.

Functionsemit(event: IEvent): void

Parameters

• event: IEvent

The event object to be emitted.

Returns void

Description

Emits a specified event.

Examples

on(eventType: number, callback: (event:IEvent) => void, context?: object): void

emitter.on(myEventType, this.onMyEventType, this);

once(eventType: number, callback: (event:IEvent) => void, context?: object): void

emitter.once(myEventType, this.onMyEventType, this);

off(eventType: number, callback: (event:IEvent) => void, context?: object): void

emitter.off(myEventType, this.onMyEventType, this);

emit(event: IEvent): void

emitter.emit(APJS.EventManager.createEvent(MY_EVENT_TYPE));

Copyright © 2025 TikTok. All rights reserved.
About TikTokHelp CenterCareersContactLegalCookies