Class EventBasedManager<Events>Abstract

    An abstract class for managers that offer an event-based API.

    Type Parameters

    • Events extends {
          [p: string]: unknown[];
      }

      An interface of events supported by this derived manager.

    Hierarchy

    Constructors

    Methods

    Constructors

    Methods

    • Removes an existing event listener.

      Type Parameters

      • Event extends string

      Parameters

      • event: Event

        The event name associated with this listener to remove.

      • listener: ((...args: Events[Event]) => void)

        The callback function to remove.

          • (...args): void
          • Parameters

            Returns void

      Returns this

      This object.

    • Add an event listener for a specific event.

      Type Parameters

      • Event extends string

      Parameters

      • event: Event

        The event name to listen for.

      • listener: ((...args: Events[Event]) => void)

        The callback function to fire when this event is received.

          • (...args): void
          • Parameters

            Returns void

      Returns this

      This object.

    • Returns a promise that waits for a single specified event to be received. Resolves with the list of arguments dispatched with the event.

      Type Parameters

      • Event extends string

      Parameters

      • event: Event

        The event name to listen for.

      • clearPredicate: ((...args: Events[Event]) => boolean) = ...

        An optional predicate to check on incoming events to validate if the correct event has been received. If omitted, will return immediately on next event type received.

          • (...args): boolean
          • Parameters

            Returns boolean

      Returns Promise<Events[Event]>