Options
All
  • Public
  • Public/Protected
  • All
Menu

Class LokiEventEmitter

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

constructor

LokiEventEmitter

Hierarchy

Index

Properties

Protected _asyncListeners

_asyncListeners: boolean = false

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

Protected _events

_events: object

A map, with each property being an array of callbacks.

Methods

addListener

  • addListener(eventName: string | string[], listener: Function): Function
  • Alias of EventEmitter.on().

    Parameters

    • eventName: string | string[]
    • listener: Function

    Returns Function

Protected emit

  • emit(eventName: string, ...data: any[]): void
  • 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)

    Parameters

    • eventName: string

      the name of the event

    • Rest ...data: any[]

      optional object passed with the event

    Returns void

on

  • on(eventName: string | string[], listener: Function): Function
  • Adds a listener to the queue of callbacks associated to an event

    Parameters

    • eventName: string | string[]

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

    • listener: Function

      callback function of listener to attach

    Returns Function

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

removeListener

  • removeListener(eventName: string | string[], listener: Function): void
  • Removes the listener at position 'index' from the event 'eventName'

    Parameters

    • eventName: string | string[]

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

    • listener: Function

      the listener callback function to remove from emitter

    Returns void

Generated using TypeDoc