Options
All
  • Public
  • Public/Protected
  • All
Menu

Hierarchy

  • EventBus

Index

Constructors

constructor

Properties

Private channels

Holds the table of all channels for the current event bus

Private maxListeners

maxListeners: number = 10

The max number of listeners that can subscribe to a channel

name

name: string

The name of the event bus

Methods

addListener

  • addListener(channel: string | symbol, listener: function, context?: any): this
  • Add a listener to a particular channel

    Parameters

    • channel: string | symbol

      The name of the channel

    • listener: function

      The listener to fire on emission

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

          • Rest ...args: any[]

          Returns void

    • Optional context: any

      The context for the the listener

    Returns this

Private allocate

  • If the channel exists with a given channel name, it will be returned. If not, a channel will be created and returned

    Parameters

    • channel: string | symbol

      The name of the channel

    Returns EventBusChannel

channelNames

  • channelNames(): Array<string | symbol>

emit

  • emit(channel: string | symbol, ...args: any[]): boolean
  • Broadcast to a listeners for a particular channel

    Parameters

    • channel: string | symbol

      The name of the channel

    • Rest ...args: any[]

      List of arguments to be supplied to the listeners

    Returns boolean

getMaxListeners

  • getMaxListeners(): number

handlers

listenerCount

  • listenerCount(channel: string | symbol): number
  • Returns the number listeners subscribed to a channel

    Parameters

    • channel: string | symbol

      The name of the channel

    Returns number

listeners

  • listeners(channel: string | symbol): Function[]
  • Get a list of the listener references for a particular channel

    Parameters

    • channel: string | symbol

      The name of the channel

    Returns Function[]

off

  • off(channel: string | symbol, listener: function): this
  • Remove a listener from a channel

    Parameters

    • channel: string | symbol

      The name of the channel

    • listener: function

      The listener for the channel

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

          • Rest ...args: any[]

          Returns void

    Returns this

on

  • on(channel: string | symbol, listener: function, context?: any): this
  • Add a listener to a particular channel

    Parameters

    • channel: string | symbol

      The name of the channel

    • listener: function

      The listner to fire on emission

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

          • Rest ...args: any[]

          Returns void

    • Optional context: any

      The context for the listener

    Returns this

once

  • once(channel: string | symbol, listener: function, context?: any): this
  • Add a listener to a particular channel that will only fire once

    Parameters

    • channel: string | symbol

      The name of the channel

    • listener: function

      The listener to fire on emission

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

          • Rest ...args: any[]

          Returns void

    • Optional context: any

      The context for the listener

    Returns this

prependListener

  • prependListener(channel: string | symbol, listener: function, context?: any): this
  • Prepend a listener to a particular channel

    Parameters

    • channel: string | symbol

      The name of the channel

    • listener: function

      The listener to fire on emission

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

          • Rest ...args: any[]

          Returns void

    • Optional context: any

      The context for the listener

    Returns this

prependOnceListener

  • prependOnceListener(channel: string | symbol, listener: function, context?: any): this
  • Prepend a listener to a particular channel that only fire once

    Parameters

    • channel: string | symbol

      The name of the channel

    • listener: function

      The listener to fire on emission

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

          • Rest ...args: any[]

          Returns void

    • Optional context: any

    Returns this

removeAllListeners

  • removeAllListeners(channel?: string | symbol): this
  • If a channel is supplied, all event listeners for that channel will be removed. However, if no channel is supplied, all channels for this event bus will be removed

    Parameters

    • Optional channel: string | symbol

      The name of the channle

    Returns this

removeListener

  • removeListener(channel: string | symbol, listener: function): this
  • Remove a listener from a channel

    Parameters

    • channel: string | symbol

      The name of the channel

    • listener: function

      The listener for the channel

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

          • Rest ...args: any[]

          Returns void

    Returns this

setMaxListeners

  • setMaxListeners(n: number): this
  • Set the max number of listeners to be applied to a particular event channel

    Parameters

    • n: number

      The number of listeners

    Returns this

Generated using TypeDoc