LokiEventEmitter is a minimalist version of EventEmitter. It enables any constructor that inherits EventEmitter to emit events and trigger listeners that have been added to the event through the on(event, callback) method

Hierarchy

Constructors

Properties

addListener: (<F>(eventName: string | string[], listener: F) => F) = ...

Type declaration

    • <F>(eventName: string | string[], listener: F): F
    • Alias of LokiEventEmitter.prototype.on addListener(eventName, listener) - adds a listener to the queue of callbacks associated to an event

      Returns

      the index of the callback in the array of listeners for a particular event

      Memberof

      LokiEventEmitter

      Type Parameters

      • F extends ((...args: any[]) => any)

      Parameters

      • eventName: string | string[]

        the name(s) of the event(s) to listen to

      • listener: F

        callback function of listener to attach

      Returns F

asyncListeners: boolean = false

Prop

boolean determines whether or not the callbacks associated with each event should happen in an async fashion or not Default is false, which means events are synchronous

Memberof

LokiEventEmitter

events: {
    [eventName: string]: ((...args: any[]) => any)[];
} = {}

Prop

a hashmap, with each property being an array of callbacks

Memberof

LokiEventEmitter

Type declaration

  • [eventName: string]: ((...args: any[]) => any)[]
save: any

Methods

  • emit(eventName, data) - emits a particular event with the option of passing optional parameters which are going to be processed by the callback provided signatures match (i.e. if passing emit(event, arg0, arg1) the listener should take two parameters)

    Memberof

    LokiEventEmitter

    Parameters

    • eventName: string

      the name of the event

    • Optional data: unknown

      optional object passed with the event

    • Optional arg: any

    Returns void

  • on(eventName, listener) - adds a listener to the queue of callbacks associated to an event

    Returns

    the index of the callback in the array of listeners for a particular event

    Memberof

    LokiEventEmitter

    Type Parameters

    • F extends ((...args: any[]) => any)

    Parameters

    • eventName: string | string[]

      the name(s) of the event(s) to listen to

    • listener: F

      callback function of listener to attach

    Returns F

  • removeListener() - removes the listener at position 'index' from the event 'eventName'

    Memberof

    LokiEventEmitter

    Parameters

    • eventName: string | string[]

      the name(s) of the event(s) which the listener is attached to

    • listener: ((...args: any[]) => any)

      the listener callback function to remove from emitter

        • (...args: any[]): any
        • Parameters

          • Rest ...args: any[]

          Returns any

    Returns void

Generated using TypeDoc