Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Announcer

This class is the based class used in AntOS event announcement system. It implements the observer pattern using simple subscribe/publish mechanism

export

Hierarchy

  • Announcer

Index

Constructors

Properties

Methods

Constructors

constructor

Properties

enable

enable: boolean

Enable/disable the announcer

memberof

Announcer

observable

The observable object that stores event name and its corresponding callback in ObservableEntryType

memberof

Announcer

Methods

disable

  • disable(): boolean
  • Disable the announcer, when this function is called all events and their callbacks will be removed

    memberof

    Announcer

    Returns boolean

off

  • off(evtName: string, callback?: (d: any) => void): void
  • Unsubscribe the callback from an event

    memberof

    Announcer

    Parameters

    • evtName: string

      event name

    • Optional callback: (d: any) => void
        • (d: any): void
        • Parameters

          • d: any

          Returns void

    Returns void

on

  • on(evtName: string, callback: (d: any) => void): void
  • Subscribe to an event, the callback will be called every time the corresponding event is trigged

    memberof

    Announcer

    Parameters

    • evtName: string

      event name

    • callback: (d: any) => void

      The corresponding callback

        • (d: any): void
        • Parameters

          • d: any

          Returns void

    Returns void

one

  • one(evtName: string, callback: (d: any) => void): void
  • Subscribe to an event, the callback will be called only once and then removed from the announcer

    memberof

    Announcer

    Parameters

    • evtName: string

      event name

    • callback: (d: any) => void

      the corresponding callback

        • (d: any): void
        • Parameters

          • d: any

          Returns void

    Returns void

trigger

  • trigger(evtName: string, data: any): void
  • Trigger an event

    memberof

    Announcer

    Parameters

    • evtName: string

      event name

    • data: any

      data object that will be send to all related callback

    Returns void