EventEmitter extends EventEmitter
The
new EventEmitter(options)
Parameter | Type | Optional | Description |
---|---|---|---|
options | EventEmitterOptions | β | - |
Properties
public static captureRejectionSymbol: (typeof captureRejectionSymbol)
- Source:
node_modules/@types/node/events.d.ts#L291
public static captureRejections: boolean
Sets or gets the default captureRejection value for all emitters.
- Source:
node_modules/@types/node/events.d.ts#L296
public static defaultMaxListeners: number
- Source:
node_modules/@types/node/events.d.ts#L297
public static errorMonitor: (typeof errorMonitor)
This symbol shall be used to install a listener for only monitoring
- Source:
node_modules/@types/node/events.d.ts#L290
Methods
public addListener(eventName, listener): EventEmitter
Alias for
Parameter | Type | Optional | Description |
---|---|---|---|
eventName | string | symbol | β | - |
listener | (args: Array<any>) => void | β | - |
- Source:
node_modules/@types/node/events.d.ts#L317
public emit(eventName, args): boolean
Synchronously calls each of the listeners registered for the event named
Parameter | Type | Optional | Description |
---|---|---|---|
eventName | string | symbol | β | - |
args | Array<any> | β | - |
- Source:
node_modules/@types/node/events.d.ts#L573
public eventNames(): Array<string | symbol>
Returns an array listing the events for which the emitter has registered listeners. The values in the array are strings or
- Source:
node_modules/@types/node/events.d.ts#L632
public getMaxListeners(): number
Returns the current max listener value for the
- Source:
node_modules/@types/node/events.d.ts#L489
public listenerCount(eventName): number
Returns the number of listeners listening to the event named
Parameter | Type | Optional | Description |
---|---|---|---|
eventName | string | symbol | β | The name of the event being listened for |
- Source:
node_modules/@types/node/events.d.ts#L579
public listeners(eventName): Array<Function>
Returns a copy of the array of listeners for the event named
Parameter | Type | Optional | Description |
---|---|---|---|
eventName | string | symbol | β | - |
- Source:
node_modules/@types/node/events.d.ts#L502
public off(eventName, listener): EventEmitter
Alias for
Parameter | Type | Optional | Description |
---|---|---|---|
eventName | string | symbol | β | - |
listener | (args: Array<any>) => void | β | - |
- Source:
node_modules/@types/node/events.d.ts#L462
public on(eventName, listener): EventEmitter
Adds the
Parameter | Type | Optional | Description |
---|---|---|---|
eventName | string | symbol | β | The name of the event. |
listener | (args: Array<any>) => void | β | The callback function |
- Source:
node_modules/@types/node/events.d.ts#L348
public once(eventName, listener): EventEmitter
Adds a one-time
Parameter | Type | Optional | Description |
---|---|---|---|
eventName | string | symbol | β | The name of the event. |
listener | (args: Array<any>) => void | β | The callback function |
- Source:
node_modules/@types/node/events.d.ts#L377
public prependListener(eventName, listener): EventEmitter
Adds the
Parameter | Type | Optional | Description |
---|---|---|---|
eventName | string | symbol | β | The name of the event. |
listener | (args: Array<any>) => void | β | The callback function |
- Source:
node_modules/@types/node/events.d.ts#L597
public prependOnceListener(eventName, listener): EventEmitter
Adds a one-time
Parameter | Type | Optional | Description |
---|---|---|---|
eventName | string | symbol | β | The name of the event. |
listener | (args: Array<any>) => void | β | The callback function |
- Source:
node_modules/@types/node/events.d.ts#L613
public rawListeners(eventName): Array<Function>
Returns a copy of the array of listeners for the event named
Parameter | Type | Optional | Description |
---|---|---|---|
eventName | string | symbol | β | - |
- Source:
node_modules/@types/node/events.d.ts#L532
public removeAllListeners(event?): EventEmitter
Removes all listeners, or those of the specified
Parameter | Type | Optional | Description |
---|---|---|---|
event | string | symbol | β | - |
- Source:
node_modules/@types/node/events.d.ts#L473
public removeListener(eventName, listener): EventEmitter
Removes the specified
Parameter | Type | Optional | Description |
---|---|---|---|
eventName | string | symbol | β | - |
listener | (args: Array<any>) => void | β | - |
- Source:
node_modules/@types/node/events.d.ts#L457
public setMaxListeners(n): EventEmitter
By default
Parameter | Type | Optional | Description |
---|---|---|---|
n | number | β | - |
- Source:
node_modules/@types/node/events.d.ts#L483
public static getEventListeners(emitter, name): Array<Function>
Returns a copy of the array of listeners for the event named
Parameter | Type | Optional | Description |
---|---|---|---|
emitter | EventEmitter | DOMEventTarget | β | - |
name | string | symbol | β | - |
- Source:
node_modules/@types/node/events.d.ts#L262
public static listenerCount(emitter, eventName): number
A class method that returns the number of listeners for the given
- β οΈ Deprecated
Parameter | Type | Optional | Description |
---|---|---|---|
emitter | EventEmitter | β | The emitter to query |
eventName | string | symbol | β | The event name |
- Source:
node_modules/@types/node/events.d.ts#L234
public static on(emitter, eventName, options?): AsyncIterableIterator<any>
const { on, EventEmitter } = require('events');
(async () => {
const ee = new EventEmitter();
// Emit later on
process.nextTick(() => {
ee.emit('foo', 'bar');
ee.emit('foo', 42);
});
for await (const event of on(ee, 'foo')) {
// The execution of this inner block is synchronous and it
// processes one event at a time (even with await). Do not use
// if concurrent execution is required.
console.log(event); // prints ['bar'] [42]
}
// Unreachable here
})();
Parameter | Type | Optional | Description |
---|---|---|---|
emitter | EventEmitter | β | - |
eventName | string | β | The name of the event being listened for |
options | StaticEventEmitterOptions | β | - |
- Source:
node_modules/@types/node/events.d.ts#L217
public static once(emitter, eventName, options?): Promise<Array<any>>
Creates a
Parameter | Type | Optional | Description |
---|---|---|---|
emitter | NodeEventTarget | β | - |
eventName | string | symbol | β | - |
options | StaticEventEmitterOptions | β | - |
- Source:
node_modules/@types/node/events.d.ts#L157
public static setMaxListeners(n?, eventTargets): void
const {
setMaxListeners,
EventEmitter
} = require('events');
const target = new EventTarget();
const emitter = new EventEmitter();
setMaxListeners(5, target, emitter);
Parameter | Type | Optional | Description |
---|---|---|---|
n | number | β | A non-negative number. The maximum number of listeners per |
eventTargets | Array<EventEmitter | DOMEventTarget> | β | - |
- Source:
node_modules/@types/node/events.d.ts#L280