Options
All
  • Public
  • Public/Protected
  • All
Menu

A utility class for objects that emit events and allow listeners to be registered on them.

EventedSupport can be used in a prototype chain of a class to wire in the event notification system. For example, you can create a custom implementation of Store interface in order to be able to emit store specific events.

Hierarchy

  • EventedSupport

Implements

Overview

Constructors

Methods

Constructors

constructor

  • Constructs the utility that allows to emit events and register event handlers.

    Parameters

    • Optional supportedEvents: string[]

      event names that the are expected to be emitted

    • Optional strictMode: boolean

      if 'true' any attempt to register a handler that is not on the supportedEvents list will throw an error.

    Returns EventedSupport

Methods

emit

  • (event: string, ...args: any[]): void
  • Emits an event. Calling this method will cause all registered callbacks for the given event type to be invoked. Any additional parameters that are passed to this function will be passed as arguments to the callback functions.

    Parameters

    • event: string

      the event type to emit

    • Rest ...args: any[]

      additional parameters that describe the emitted event

    Returns void

on

  • (event: string, callback: (...args: any[]) => void, context?: any): Handle
  • Parameters

    • event: string
    • callback: (...args: any[]) => void
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    • Optional context: any

    Returns Handle

Static on

  • (target: Evented, event: string, callback: () => void, context?: any): Handle
  • Registers a callback function on the specified target object for a given event type.

    Parameters

    • target: Evented

      the target object

    • event: string

      the event type to register on

    • callback: () => void

      the callback function to register

        • (): void
        • Returns void

    • Optional context: any

      the context in which the callback function should be invoked implementation dependent.

    Returns Handle

    a handle to the registered callback with a single function 'remove'. This function can be used to unregister the callback function.

Static once

  • (target: Evented, event: string, callback: () => void, context?: any): Handle
  • Registers a callback function on the specified target object for a given event type. This function behaves identical to 'on' with the exception that the registered callback function will be automatically removed when it has been triggered one time.

    Parameters

    • target: Evented

      the target object

    • event: string

      the event type to register on

    • callback: () => void

      the callback function to register

        • (): void
        • Returns void

    • Optional context: any

      the context in which the callback function should be invoked implementation dependent.

    Returns Handle

    a handle to the registered callback with a single function 'remove'. This function can be used to unregister the callback function.

Legend

  • Module
  • Object literal
  • Variable
  • Function
  • Function with type parameter
  • Index signature
  • Type alias
  • Type alias with type parameter
  • Enumeration
  • Enumeration member
  • Property
  • Method
  • Interface
  • Interface with type parameter
  • Constructor
  • Property
  • Method
  • Index signature
  • Class
  • Class with type parameter
  • Constructor
  • Property
  • Method
  • Accessor
  • Index signature
  • Inherited constructor
  • Inherited property
  • Inherited method
  • Inherited accessor
  • Protected property
  • Protected method
  • Protected accessor
  • Private property
  • Private method
  • Private accessor
  • Static property
  • Static method