Skip to main content
Version: Version 5 beta

Interface: EventHandler<TEventMap>

Base interface for components with event handling capabilities.

Extended by

Type Parameters

TEventMap

TEventMap extends Record<string, (…args) => any>

A record mapping event names to their callback signatures.

Methods

addEventListener()

addEventListener<K>(eventName, callback): void

Adds an event listener for a specified event.

Type Parameters

K

K extends string | number | symbol

Parameters

eventName

K

The name of the event to listen for.

callback

TEventMap[K]

The callback function to execute when the event is triggered.

Returns

void


removeEventListener()

removeEventListener<K>(eventName, callback): void

Removes an event listener for a specified event.

Type Parameters

K

K extends string | number | symbol

Parameters

eventName

K

The name of the event to stop listening for.

callback

TEventMap[K]

The callback function to remove.

Returns

void