Observer

Observer

new Observer()

Creates an observer instance.

Source:

Methods

fire(name, …args) → {void}

Executes all handlers attached for the specified event type.

The event specified in name is an RTM or Subscription event that has an attached event handler function (see the on() function).

Source:
Parameters:
Name Type Attributes Description
name string

name of an event that has attached handlers

args Object <repeatable>

event arguments.

Returns:
Type:
void

off(name, fn) → {void}

Removes an event handler.

The event specified in name is an RTM or Subscription event that has an attached event handler function (see the on() function).

The Protocol Data Unit (PDU) for the event is passed to the fn function parameter.

Source:
Parameters:
Name Type Description
name string

event name

fn function

event handler function

Returns:
Type:
void

on(name, fn) → {void}

Attaches an event handler function for the event specified in name.

The event is usually related to a client or subscription state. It may also be an event that occurs when the client or subscription receives information from RTM. For example, the the following are RTM client events:

  • data: The client received a PDU from RTM.
  • enter-connected: The client is now connected to RTM.
A possible event for a Subscription is enter-subscribed.

The fn parameter is a function that's invoked when the event occurs. The PDU for the event is passed to this function.

Source:
Parameters:
Name Type Description
name string

event name

fn function

event handler function

Returns:
Type:
void