Skip to main content

Eventable

Implemented by

Index

Methods

emit

  • emit(eventName: string, event: any): void
  • Emits an event for target


    Parameters

    • eventName: string

      The name of the event to publish

    • event: any

      Optionally pass an event data object to the handler

    Returns void

off

  • off(eventName: string, handler?: Handler<any>): void
  • Unsubscribe an event handler(s) from an event. If a specific handler is specified for an event, only that handler will be unsubscribed. Otherwise all handlers will be unsubscribed for that event.


    Parameters

    • eventName: string

      The name of the event to unsubscribe

    • optionalhandler: Handler<any>

      Optionally the specific handler to unsubscribe

    Returns void

on

  • on(eventName: string, handler: Handler<any>): void
  • Subscribe an event handler to a particular event name, multiple handlers per event name are allowed.


    Parameters

    • eventName: string

      The name of the event to subscribe to

    • handler: Handler<any>

      The handler callback to fire on this event

    Returns void

once

  • once(eventName: string, handler: Handler<any>): void
  • Once listens to an event once then auto unsubscribes from that event


    Parameters

    • eventName: string

      The name of the event to subscribe to once

    • handler: Handler<any>

      The handler of the event that will be auto unsubscribed

    Returns void