Class: AsyncEmitter

utils.AsyncEmitter

new AsyncEmitter()

Represents a promise-resolving event emitter.

Source:
See:
  • EventEmitter

Methods

(private) _push(type, handler, once)

Push a listener.

Parameters:
Name Type Description
type String
handler function
once Boolean
Source:

_unshift(type, handler, once)

Unshift a listener.

Parameters:
Name Type Description
type String
handler function
once Boolean
Source:

addListener(type, handler)

Add a listener.

Parameters:
Name Type Description
type String
handler function
Source:

emit(type, …args) → {Promise}

Emit an event. Wait for promises to resolve.

Parameters:
Name Type Attributes Description
type String
args Object <repeatable>
Source:
Returns:
Type
Promise

listenerCount(type)

Get listener count for an event.

Parameters:
Name Type Description
type String
Source:

listeners(type) → {Array:.<function()>}

Get listeners array.

Parameters:
Name Type Description
type String
Source:
Returns:
Type
Array:.<function()>

on(type, handler)

Add a listener.

Parameters:
Name Type Description
type String
handler function
Source:

once(type, handler)

Add a listener to execute once.

Parameters:
Name Type Description
type String
handler function
Source:

prependListener(type, handler)

Prepend a listener.

Parameters:
Name Type Description
type String
handler function
Source:

prependOnceListener(type, handler)

Prepend a listener to execute once.

Parameters:
Name Type Description
type String
handler function
Source:

removeAllListeners(typenullable)

Remove all listeners.

Parameters:
Name Type Attributes Description
type String <nullable>
Source:

removeListener(type, handler)

Remove a listener.

Parameters:
Name Type Description
type String
handler function
Source:

setMaxListeners(max)

Set max listeners.

Parameters:
Name Type Description
max Number
Source:

tryEmit(type, …args) → {Promise}

Emit an event. Ignore rejections.

Parameters:
Name Type Attributes Description
type String
args Object <repeatable>
Source:
Returns:
Type
Promise