Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface Emitter

The base emiter class, used by Socket and Manager

Hierarchy

Index

Methods

addEventListener

  • addEventListener(event: string, fn: Function): Emitter

emit

  • emit(event: string, ...args: any[]): Emitter
  • Emits 'event' with the given args

    Parameters

    • event: string

      The event that we want to emit

    • Rest ...args: any[]

      Optional arguments to emit with the event

    Returns Emitter

    Emitter

hasListeners

  • hasListeners(event: string): boolean
  • Returns if we have listeners for a particular event

    Parameters

    • event: string

      The event that we want to check if we've listeners for

    Returns boolean

    True if we have listeners for this event, false otherwise

listeners

  • listeners(event: string): Function[]
  • Returns all the callbacks for a particular event

    Parameters

    • event: string

      The event that we're looking for the callbacks of

    Returns Function[]

    An array of callback Functions, or an empty array if we don't have any

off

  • off(event: string, fn?: Function): Emitter
  • Removes a listener for a particular type of event. This will either remove a specific listener, or all listeners for this type of event

    Parameters

    • event: string

      The event that we want to remove the listener of

    • Optional fn: Function

      The function to remove, or null if we want to remove all functions

    Returns Emitter

    This Emitter

on

  • on(event: string, fn: Function): Emitter
  • Adds a listener for a particular event. Calling multiple times will add multiple listeners

    Parameters

    • event: string

      The event that we're listening for

    • fn: Function

      The function to call when we get the event. Parameters depend on the event in question

    Returns Emitter

    This Emitter

once

  • once(event: string, fn: Function): Emitter
  • Adds a listener for a particular event that will be invoked a single time before being automatically removed

    Parameters

    • event: string

      The event that we're listening for

    • fn: Function

      The function to call when we get the event. Parameters depend on the event in question

    Returns Emitter

    This Emitter

removeAllListeners

removeEventListener

  • removeEventListener(event: string, fn?: Function): Emitter
  • see

    off( event, fn )

    Parameters

    • event: string
    • Optional fn: Function

    Returns Emitter

removeListener

  • removeListener(event: string, fn?: Function): Emitter
  • see

    off( event, fn )

    Parameters

    • event: string
    • Optional fn: Function

    Returns Emitter

Generated using TypeDoc