Overrides EventEmitter.constructor
Private
Readonly
_appPrivate
_openPrivate
Readonly
_ourPrivate
Readonly
_packetPrivate
_packetsOverrides EventEmitter.addListener
Overrides EventEmitter.off
Static
Readonly
captureInherited from EventEmitter.captureRejectionSymbol
Static
captureSets or gets the default captureRejection value for all emitters.
Inherited from EventEmitter.captureRejections
Static
defaultInherited from EventEmitter.defaultMaxListeners
Static
Readonly
errorThis symbol shall be used to install a listener for only monitoring'error'
events. Listeners installed using this symbol are called before the regular'error'
listeners are called.
Installing a listener using this symbol does not change the behavior once an'error'
event is emitted, therefore the process will still crash if noregular'error'
listener is installed.
Inherited from EventEmitter.errorMonitor
Private
_beginPrivate
_buildPrivate
_handlePrivate
_opensendId of packet (can be used to identify packet when exception event occurs)
sendId of packet (can be used to identify packet when exception event occurs)
sendId of packet (can be used to identify packet when exception event occurs)
sendId of packet (can be used to identify packet when exception event occurs)
sendId of packet (can be used to identify packet when exception event occurs)
sendId of packet (can be used to identify packet when exception event occurs)
sendId of packet (can be used to identify packet when exception event occurs)
sendId of packet (can be used to identify packet when exception event occurs)
use null to remove a previously applied filter
sendId of packet (can be used to identify packet when exception event occurs)
Optional
epsilon:numberOptional
datumId:numbersendId of packet (can be used to identify packet when exception event occurs)
Optional
dataType:SimConnectDataTypeOptional
epsilon:numberOptional
datumId:numbersendId of packet (can be used to identify packet when exception event occurs)
sendId of packet (can be used to identify packet when exception event occurs)
sendId of packet (can be used to identify packet when exception event occurs)
sendId of packet (can be used to identify packet when exception event occurs)
sendId of packet (can be used to identify packet when exception event occurs)
sendId of packet (can be used to identify packet when exception event occurs)
sendId of packet (can be used to identify packet when exception event occurs)
sendId of packet (can be used to identify packet when exception event occurs)
sendId of packet (can be used to identify packet when exception event occurs)
Optional
options:ConnectionOptionssendId of packet (can be used to identify packet when exception event occurs)
Rest
...args:Parameters<SimConnectRecvEvents[U]>Overrides EventEmitter.emit
sendId of packet (can be used to identify packet when exception event occurs)
sendId of packet (can be used to identify packet when exception event occurs)
sendId of packet (can be used to identify packet when exception event occurs)
Returns an array listing the events for which the emitter has registeredlisteners. The values in the array are strings orSymbol
s.
constEventEmitter =require('events');
constmyEE =newEventEmitter();
myEE.on('foo', ()=> {});
myEE.on('bar', ()=> {});
constsym =Symbol('symbol');
myEE.on(sym, ()=> {});
console.log(myEE.eventNames());
// Prints: [ 'foo', 'bar', Symbol(symbol) ]
v6.0.0
Inherited from EventEmitter.eventNames
sendId of packet (can be used to identify packet when exception event occurs)
sendId of packet (can be used to identify packet when exception event occurs)
sendId of packet (can be used to identify packet when exception event occurs)
sendId of packet (can be used to identify packet when exception event occurs)
Optional
flags:numbersendId of packet (can be used to identify packet when exception event occurs)
sendId of packet (can be used to identify packet when exception event occurs)
Returns the current max listener value for theEventEmitter
which is eitherset byemitter.setMaxListeners(n)
or defaults todefaultMaxListeners.
v1.0.0
Inherited from EventEmitter.getMaxListeners
Returns the number of listeners listening to the event namedeventName
.
The name of the event being listened for
v3.2.0
Inherited from EventEmitter.listenerCount
Returns a copy of the array of listeners for the event namedeventName
.
server.on('connection', (stream)=> {
console.log('someone connected!');
});
console.log(util.inspect(server.listeners('connection')));
// Prints: [ [Function] ]
v0.1.26
Inherited from EventEmitter.listeners
sendId of packet (can be used to identify packet when exception event occurs)
Optional
eventName:stringsendId of packet (can be used to identify packet when exception event occurs)
Optional
downValue:numberOptional
clientEventUpID:numberOptional
upValue:numberOptional
maskable:booleansendId of packet (can be used to identify packet when exception event occurs)
use mapInputEventToClientEventEx1 instead
Optional
downValue:numberOptional
clientEventUpID:numberOptional
upValue:numberOptional
maskable:booleansendId of packet (can be used to identify packet when exception event occurs)
Optional
title:stringOptional
prompt:stringRest
...items:string[]sendId of packet (can be used to identify packet when exception event occurs)
since MSFS (KittyHawk)
sendId of packet (can be used to identify packet when exception event occurs)
since MSFS (KittyHawk)
sendId of packet (can be used to identify packet when exception event occurs)
since MSFS (KittyHawk)
sendId of packet (can be used to identify packet when exception event occurs)
since MSFS (KittyHawk)
sendId of packet (can be used to identify packet when exception event occurs)
since MSFS (KittyHawk)
Overrides EventEmitter.on
Overrides EventEmitter.once
Adds thelistener
function to thebeginning of the listeners array for theevent namedeventName
. No checks are made to see if thelistener
hasalready been added. Multiple calls passing the same combination ofeventName
andlistener
will result in thelistener
being added, and called, multipletimes.
server.prependListener('connection', (stream)=> {
console.log('someone connected!');
});
Returns a reference to theEventEmitter
, so that calls can be chained.
The name of the event.
The callback function
Rest
...args:any[]v6.0.0
Inherited from EventEmitter.prependListener
Adds aone-timelistener
function for the event namedeventName
to the_beginning_ of the listeners array. The next timeeventName
is triggered, thislistener is removed, and then invoked.
server.prependOnceListener('connection', (stream)=> {
console.log('Ah, we have our first user!');
});
Returns a reference to theEventEmitter
, so that calls can be chained.
The name of the event.
The callback function
Rest
...args:any[]v6.0.0
Inherited from EventEmitter.prependOnceListener
Returns a copy of the array of listeners for the event namedeventName
,including any wrappers (such as those created by.once()
).
constemitter =newEventEmitter();
emitter.once('log', ()=>console.log('log once'));
// Returns a new Array with a function `onceWrapper` which has a property
// `listener` which contains the original listener bound above
constlisteners =emitter.rawListeners('log');
constlogFnWrapper =listeners[0];
// Logs "log once" to the console and does not unbind the `once` event
logFnWrapper.listener();
// Logs "log once" to the console and removes the listener
logFnWrapper();
emitter.on('log', ()=>console.log('log persistently'));
// Will return a new Array with a single function bound by `.on()` above
constnewListeners =emitter.rawListeners('log');
// Logs "log persistently" twice
newListeners[0]();
emitter.emit('log');
v9.4.0
Inherited from EventEmitter.rawListeners
Overrides EventEmitter.removeAllListeners
sendId of packet (can be used to identify packet when exception event occurs)
sendId of packet (can be used to identify packet when exception event occurs)
Overrides EventEmitter.removeListener
Optional
origin:OOptional
interval:IOptional
limit:LsendId of packet (can be used to identify packet when exception event occurs)
Optional
flags:DataRequestFlagOptional
origin:numberOptional
interval:numberOptional
limit:numbersendId of packet (can be used to identify packet when exception event occurs)
Listen forSimConnectRecvEvents.simObjectData to get the data.
constLIVE_DATA_REQ_ID =1234;
handle.addToDataDefinition(
LIVE_DATA_REQ_ID,
'STRUCT LATLONALT',
null,
SimConnectDataType.LATLONALT
);
handle.on('simObjectData',recvSimObjectData=> {
if (recvSimObjectData.requestID ===LIVE_DATA_REQ_ID) {
console.log(readLatLonAlt(recvSimObjectData.data));
}
});
sendId of packet (can be used to identify packet when exception event occurs)
Listen forSimConnectRecvEvents.simObjectDataByType to get the data.
sendId of packet (can be used to identify packet when exception event occurs)
sendId of packet (can be used to identify packet when exception event occurs)
Optional
region:stringOptional
type:IcaoTypesendId of packet (can be used to identify packet when exception event occurs)
Optional
parkingIndices:number[]sendId of packet (can be used to identify packet when exception event occurs)
sendId of packet (can be used to identify packet when exception event occurs)
Optional
keyChoice1:stringOptional
keyChoice2:stringOptional
keyChoice3:stringsendId of packet (can be used to identify packet when exception event occurs)
sendId of packet (can be used to identify packet when exception event occurs)
sendId of packet (can be used to identify packet when exception event occurs)
sendId of packet (can be used to identify packet when exception event occurs)
sendId of packet (can be used to identify packet when exception event occurs)
sendId of packet (can be used to identify packet when exception event occurs)
sendId of packet (can be used to identify packet when exception event occurs)
By defaultEventEmitter
s will print a warning if more than10
listeners areadded for a particular event. This is a useful default that helps findingmemory leaks. Theemitter.setMaxListeners()
method allows the limit to bemodified for this specificEventEmitter
instance. The value can be set toInfinity
(or0
) to indicate an unlimited number of listeners.
Returns a reference to theEventEmitter
, so that calls can be chained.
v0.3.5
Inherited from EventEmitter.setMaxListeners
sendId of packet (can be used to identify packet when exception event occurs)
sendId of packet (can be used to identify packet when exception event occurs)
sendId of packet (can be used to identify packet when exception event occurs)
sendId of packet (can be used to identify packet when exception event occurs)
sendId of packet (can be used to identify packet when exception event occurs)
sendId of packet (can be used to identify packet when exception event occurs)
sendId of packet (can be used to identify packet when exception event occurs)
sendId of packet (can be used to identify packet when exception event occurs)
since MSFS (KittyHawk)
sendId of packet (can be used to identify packet when exception event occurs)
sendId of packet (can be used to identify packet when exception event occurs)
sendId of packet (can be used to identify packet when exception event occurs)
sendId of packet (can be used to identify packet when exception event occurs)
sendId of packet (can be used to identify packet when exception event occurs)
sendId of packet (can be used to identify packet when exception event occurs)
sendId of packet (can be used to identify packet when exception event occurs)
since MSFS (KittyHawk)
sendId of packet (can be used to identify packet when exception event occurs)
since MSFS (KittyHawk)
sendId of packet (can be used to identify packet when exception event occurs)
since MSFS (KittyHawk)
sendId of packet (can be used to identify packet when exception event occurs)
since MSFS (KittyHawk)
Optional
flags:numbersendId of packet (can be used to identify packet when exception event occurs)
since MSFS (KittyHawk)
sendId of packet (can be used to identify packet when exception event occurs)
since MSFS (KittyHawk)
sendId of packet (can be used to identify packet when exception event occurs)
since MSFS (KittyHawk)
sendId of packet (can be used to identify packet when exception event occurs)
since MSFS (KittyHawk)
sendId of packet (can be used to identify packet when exception event occurs)
since MSFS (KittyHawk)
sendId of packet (can be used to identify packet when exception event occurs)
since MSFS (KittyHawk)
sendId of packet (can be used to identify packet when exception event occurs)
since MSFS (KittyHawk)
sendId of packet (can be used to identify packet when exception event occurs)
since MSFS (KittyHawk)
sendId of packet (can be used to identify packet when exception event occurs)
since MSFS (KittyHawk)
sendId of packet (can be used to identify packet when exception event occurs)
since MSFS (KittyHawk)
Static
getReturns a copy of the array of listeners for the event namedeventName
.
ForEventEmitter
s this behaves exactly the same as calling.listeners
onthe emitter.
ForEventTarget
s this is the only way to get the event listeners for theevent target. This is useful for debugging and diagnostic purposes.
const {getEventListeners,EventEmitter } =require('events');
{
constee =newEventEmitter();
constlistener = ()=>console.log('Events are fun');
ee.on('foo',listener);
getEventListeners(ee,'foo');// [listener]
}
{
constet =newEventTarget();
constlistener = ()=>console.log('Events are fun');
et.addEventListener('foo',listener);
getEventListeners(et,'foo');// [listener]
}
v15.2.0
Inherited from EventEmitter.getEventListeners
Static
listenerA class method that returns the number of listeners for the giveneventName
registered on the givenemitter
.
const {EventEmitter,listenerCount } =require('events');
constmyEmitter =newEventEmitter();
myEmitter.on('event', ()=> {});
myEmitter.on('event', ()=> {});
console.log(listenerCount(myEmitter,'event'));
// Prints: 2
The emitter to query
The event name
v0.9.12
Since v3.2.0 - UselistenerCount
instead.
Inherited from EventEmitter.listenerCount
Static
onconst {on,EventEmitter } =require('events');
(async ()=> {
constee =newEventEmitter();
// Emit later on
process.nextTick(()=> {
ee.emit('foo','bar');
ee.emit('foo',42);
});
forawait (consteventofon(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
})();
Returns anAsyncIterator
that iterateseventName
events. It will throwif theEventEmitter
emits'error'
. It removes all listeners whenexiting the loop. Thevalue
returned by each iteration is an arraycomposed of the emitted event arguments.
AnAbortSignal
can be used to cancel waiting on events:
const {on,EventEmitter } =require('events');
constac =newAbortController();
(async ()=> {
constee =newEventEmitter();
// Emit later on
process.nextTick(()=> {
ee.emit('foo','bar');
ee.emit('foo',42);
});
forawait (consteventofon(ee,'foo', {signal:ac.signal })) {
// 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
})();
process.nextTick(()=>ac.abort());
The name of the event being listened for
Optional
options:StaticEventEmitterOptionsthat iterateseventName
events emitted by theemitter
v13.6.0, v12.16.0
Inherited from EventEmitter.on
Static
onceCreates aPromise
that is fulfilled when theEventEmitter
emits the givenevent or that is rejected if theEventEmitter
emits'error'
while waiting.ThePromise
will resolve with an array of all the arguments emitted to thegiven event.
This method is intentionally generic and works with the web platformEventTarget interface, which has no special'error'
eventsemantics and does not listen to the'error'
event.
const {once,EventEmitter } =require('events');
asyncfunctionrun() {
constee =newEventEmitter();
process.nextTick(()=> {
ee.emit('myevent',42);
});
const [value] =awaitonce(ee,'myevent');
console.log(value);
consterr =newError('kaboom');
process.nextTick(()=> {
ee.emit('error',err);
});
try {
awaitonce(ee,'myevent');
}catch (err) {
console.log('error happened',err);
}
}
run();
The special handling of the'error'
event is only used whenevents.once()
is used to wait for another event. Ifevents.once()
is used to wait for the'error'
event itself, then it is treated as any other kind of event withoutspecial handling:
const {EventEmitter,once } =require('events');
constee =newEventEmitter();
once(ee,'error')
.then(([err])=>console.log('ok',err.message))
.catch((err)=>console.log('error',err.message));
ee.emit('error',newError('boom'));
// Prints: ok boom
AnAbortSignal
can be used to cancel waiting for the event:
const {EventEmitter,once } =require('events');
constee =newEventEmitter();
constac =newAbortController();
asyncfunctionfoo(emitter,event,signal) {
try {
awaitonce(emitter,event, {signal });
console.log('event emitted!');
}catch (error) {
if (error.name ==='AbortError') {
console.error('Waiting for the event was canceled!');
}else {
console.error('There was an error',error.message);
}
}
}
foo(ee,'foo',ac.signal);
ac.abort();// Abort waiting for the event
ee.emit('foo');// Prints: Waiting for the event was canceled!
Optional
options:StaticEventEmitterOptionsv11.13.0, v10.16.0
Inherited from EventEmitter.once
Optional
options:StaticEventEmitterOptionsInherited from EventEmitter.once
Static
setconst {
setMaxListeners,
EventEmitter
} =require('events');
consttarget =newEventTarget();
constemitter =newEventEmitter();
setMaxListeners(5,target,emitter);
Optional
n:numberA non-negative number. The maximum number of listeners perEventTarget
event.
Rest
...eventTargets:(EventEmitter |DOMEventTarget)[]v15.4.0
Inherited from EventEmitter.setMaxListeners
Generated usingTypeDoc