Class: Emitter

Emitter(obj, prototypeMode)

Emitter

Constructor

new Emitter(obj, prototypeMode)

Parameters:
Name Type Description
obj
prototypeMode Boolean Defaults to true. Set to true to add emitter methods to the the passed object's prototype property e.g. obj.prototype.on = emitter.on. Set to false to add emitter methods the object directly e.g. obj.on = emitter.on.
Source:

Methods

(static) deferEmit(eventName, dataopt)

Queues an event to be fired. This has automatic de-bouncing so that any events of the same type that occur within 100 milliseconds of a previous one will all be wrapped into a single emit rather than emitting tons of events for lots of chained inserts etc. Only the data from the last de-bounced event will be emitted.
Parameters:
Name Type Attributes Description
eventName String The name of the event to emit.
data * <optional>
Optional data to emit with the event.
Source:

(static) emit(event) → {*}

Emit an event.
Parameters:
Name Type Description
event String The event to emit.
Source:
Returns:
Type
*

(static) emit(event, data) → {*}

Emit an event with data.
Parameters:
Name Type Description
event String The event to emit.
data * Data to emit with the event.
Source:
Returns:
Type
*

(static) emitStatic(event) → {*}

Emit an event that will fire on listeners even when the listener is registered AFTER the event has been emitted.
Parameters:
Name Type Description
event String The event to emit.
Source:
Returns:
Type
*

(static) emitStatic(event, data) → {*}

Emit an event with data that will fire on listeners even when the listener is registered AFTER the event has been emitted.
Parameters:
Name Type Description
event String The event to emit.
data * Data to emit with the event.
Source:
Returns:
Type
*

(static) emitStatic(event) → {*}

Remove a static event emitter.
Parameters:
Name Type Description
event String The event to remove static emitter for.
Source:
Returns:
Type
*

(static) emitStaticId(event)

Require an id to emit.
Parameters:
Name Type Description
event
Source:

(static) emitStaticId(event, id) → {*}

Emit an event that will fire on listeners even when the listener is registered AFTER the event has been emitted.
Parameters:
Name Type Description
event String The event to emit.
id String The id of the event to emit.
Source:
Returns:
Type
*

(static) emitStaticId(event, id, dataopt) → {*}

Emit an event that will fire on listeners even when the listener is registered AFTER the event has been emitted.
Parameters:
Name Type Attributes Description
event String The event to emit.
id String The id of the event to emit.
data * <optional>
The data to emit with the event.
Source:
Returns:
Type
*

(static) off(event, id)

Cancels all listeners for an event based on the passed event name and id.
Parameters:
Name Type Description
event String The event name to cancel listeners for.
id * The ID to cancel all listeners for.
Source:

(static) off(event, id, listener)

Cancels an event listener based on an event name, id and listener function.
Parameters:
Name Type Description
event String The event to cancel listener for.
id String The ID of the event to cancel listening for.
listener function The event listener function used in the on() or once() call to cancel.
Source:

(static) off(event, listener) → {*}

Cancels the event listener for the passed event and listener function.
Parameters:
Name Type Description
event String The event to cancel listener for.
listener function The event listener function used in the on() or once() call to cancel.
Source:
Returns:
Type
*

(static) off(event) → {*}

Cancels all event listeners for the passed event.
Parameters:
Name Type Description
event String The name of the event.
Source:
Returns:
Type
*

(static) on(event, id, listener)

Attach an event listener to the passed event only if the passed id matches the document id for the event being fired.
Parameters:
Name Type Description
event String The name of the event to listen for.
id * The document id to match against.
listener function The method to call when the event is fired.
Source:

(static) on(event, listener)

Attach an event listener to the passed event.
Parameters:
Name Type Description
event String The name of the event to listen for.
listener function The method to call when the event is fired.
Source:

(static) once(event, id, listener)

Attach an event listener to the passed event only if the passed id matches the document id for the event being fired.
Parameters:
Name Type Description
event String The name of the event to listen for.
id * The document id to match against.
listener function The method to call when the event is fired.
Source:

(static) once(event, listener)

Attach an event listener to the passed event which will only fire once.
Parameters:
Name Type Description
event String The name of the event to listen for.
listener function The method to call when the event is fired.
Source:

(static) willEmit(event) → {boolean}

Checks if an event has any event listeners or not.
Parameters:
Name Type Description
event String The name of the event to check for.
Source:
Returns:
True if one or more event listeners are registered for the event. False if none are found.
Type
boolean

(static) willEmitId(event, id) → {boolean}

Checks if an event has any event listeners or not based on the passed id.
Parameters:
Name Type Description
event String The name of the event to check for.
id String The event ID to check for.
Source:
Returns:
True if one or more event listeners are registered for the event. False if none are found.
Type
boolean