Class Callbacks<Types, Ctx>

Manages event callbacks with features like one-time execution, protection, and delays.

Type Parameters

Constructors

Accessors

Methods

Constructors

Accessors

Methods

  • Registers a callback for an event.

    Type Parameters

    • T extends string | number | symbol

    Parameters

    Returns { id: string; remove: () => boolean }

    Callback ID and a removal function.

  • Triggers all callbacks for a given event.

    Type Parameters

    • T extends string | number | symbol

    Parameters

    • target: T

      Event name to trigger.

    • arg: Types[T]

      Argument to pass to the callbacks.

    Returns void

  • Removes a callback by its ID.

    Parameters

    • id: string

      ID of the callback to remove.

    Returns boolean

    true if the callback was removed, false otherwise.