-
-
Release all resources of EventEmitter instance:
unregister any listeners and unlink any external references
(e.g. thisArg if given in constructor).
-
emit(type, args){boolean}
-
Emit an event to registered listeners.
Name |
Type |
Description |
type |
string
|
the event type that will be emitted |
args |
any
|
optional
repeatable
OPTIONAL arguments that will be emitted to
the listeners |
Returns:
Type |
Description |
boolean
|
true if at least one listener was notified |
-
-
Check if the EventEmitter instance has any listener registered.
NOTE: only considers hooks, if hooks are enabled and a list of valid events
was specified (see constructor).
Returns:
Type |
Description |
boolean
|
true if no listener is registered |
-
-
Get a list of event types (if no argument is given) or a list of registered
listeners for an event type (if event type is given).
Name |
Type |
Description |
type |
string
|
optional
the event type.
If omitted returns a list of event types, or
undefined , if there are no listener
for any event registered.
If an event type is specified, returns a list of
listeners, or undefined , if no
listeners for the event type or registered. |
Returns:
Type |
Description |
Array.<function()>
|
Array.<String>
|
a list of listeners or a list of
event types or undefined , if there
are none. |
-
has(type, listener){boolean}
-
Check if listener is registered for an event.
Name |
Type |
Description |
type |
string
|
the event type |
listener |
function
|
optional
OPTIONAL
The listener to be checked.
If omitted, it will be checked, if there is any listener
of the event type. |
Returns:
Type |
Description |
boolean
|
true if the listener (or any if listener
was not specified) is registered for the event type |
-
off(type, listener){boolean}
-
Unregister a listener for an event.
Name |
Type |
Description |
type |
string
|
the event type |
listener |
function
|
optional
OPTIONAL
The listener to be removed.
If omitted, all listeners for the event type will be
removed. |
Returns:
Type |
Description |
boolean
|
true if the listener was removed |
-
on(type, listener){boolean}
-
Register a listener for an event type.
Will be ignored, if the listener already is registered for that event type.
If a list of supported event types is specified for the EventEmitter instance,
and type
is not a supported type, an error will be thrown.
Name |
Type |
Description |
type |
string
|
the event type |
listener |
function
|
this listener that will be registered |
Throws:
Error if the event type is not supported by the EventEmitter instance
Returns:
Type |
Description |
boolean
|
true if the listener was registered |
-
once(type, listener){boolean}
-
Register a listener for an event type to be called one time.
Name |
Type |
Description |
type |
string
|
the event type |
listener |
function
|
this listener that will be registered |
- See:
-
Throws:
Error if the event type is not supported by the EventEmitter instance
Returns:
Type |
Description |
boolean
|
true if the listener was registered |
-
-
Verifies that an event type can be used with the EventEmitter instance
(see events
argument in constructor).
Name |
Type |
Description |
type |
string
|
the event type to check |
Throws:
Error if the event type is not supported by the EventEmitter instance