Event

Event

Event Represents an Chat event.

Constructor

new Event()

Source:
Fires:
  • $.emitted

Extends

Members

(readonly) channel :String

Source:
See:

The Chat#channel that this event is registered to.

Type:
  • String

(readonly) chat :Chat

Source:

Events are always a property of a Chat. Responsible for listening to specific events and firing events when they occur.

Type:

event :String

Source:

The string representation of the event. This is supplied as the first parameter to Chat#on

Type:
  • String

name :String

Source:
Overrides:
  • RootEmitter#name

A name that identifies this class

Type:
  • String

Methods

off(event)

Source:
Overrides:

Stop a callback from listening to an event.

Example
let callback = function(payload;) {
   console.log('something happend!');
};
object.on('event', callback);
// ...
object.off('event', callback);
Parameters:
Name Type Description
event String

The event name

on(event, cb)

Source:
Overrides:

Listen for a specific event and fire a callback when it's emitted. Supports wildcard matching.

Example
// Get notified whenever someone joins the room
object.on('event', (payload) => {
    console.log('event was fired').
})

// Get notified of event.a and event.b
object.on('event.*', (payload) => {
    console.log('event.a or event.b was fired').;
})
Parameters:
Name Type Description
event String

The event name

cb function

The function to run when the event is emitted

onAny(callback)

Source:
Overrides:

Listen for any event on this object and fire a callback when it's emitted

Example
object.onAny((event, payload) => {
    console.log('All events trigger this.');
});
Parameters:
Name Type Description
callback function

The function to run when any event is emitted. First parameter is the event name and second is the payload.

once(event, callback)

Source:
Overrides:

Listen for an event and only fire the callback a single time

Example
object.once('message', => (event, payload) {
    console.log('This is only fired once!');
});
Parameters:
Name Type Description
event String

The event name

callback function

The function to run once

plugin(module)

Source:
Overrides:
Tutorials:
  • Tutorial: using

Binds a plugin to this object

Parameters:
Name Type Description
module Object

The plugin module

Events

$.emitted

Source:
Properties:
Name Type Description
data Object

The message payload

Message successfully published