Interface Events

Interface for event handling functionality

interface Events {
    dispatch: <T>(event: string, data: T) => void;
    emit: <T>(event: string, data: T) => void;
    listen: <T>(event: string, callback: EventCallback<T>) => void;
    off: <T>(event: string, callback: EventCallback<T>) => void;
    on: <T>(event: string, callback: EventCallback<T>) => void;
    unlisten: <T>(event: string, callback: EventCallback<T>) => void;
    clear(): void;
}

Properties

Methods

Properties

dispatch: <T>(event: string, data: T) => void

Dispatch an event with data

Type declaration

    • <T>(event: string, data: T): void
    • Type Parameters

      • T

      Parameters

      • event: string

        Event name

      • data: T

        Event data

      Returns void

emit: <T>(event: string, data: T) => void

Alias for dispatch

Type declaration

    • <T>(event: string, data: T): void
    • Type Parameters

      • T

      Parameters

      • event: string

        Event name

      • data: T

        Event data

      Returns void

listen: <T>(event: string, callback: EventCallback<T>) => void

Alias for on

Type declaration

    • <T>(event: string, callback: EventCallback<T>): void
    • Type Parameters

      • T

      Parameters

      Returns void

off: <T>(event: string, callback: EventCallback<T>) => void

Remove an event listener

Type declaration

    • <T>(event: string, callback: EventCallback<T>): void
    • Type Parameters

      • T

      Parameters

      Returns void

on: <T>(event: string, callback: EventCallback<T>) => void

Add an event listener

Type declaration

    • <T>(event: string, callback: EventCallback<T>): void
    • Type Parameters

      • T

      Parameters

      Returns void

unlisten: <T>(event: string, callback: EventCallback<T>) => void

Alias for off

Type declaration

    • <T>(event: string, callback: EventCallback<T>): void
    • Type Parameters

      • T

      Parameters

      Returns void

Methods