Hi all,
So, a silly question, I have a node with one input port, and two output ports. The first output port is used to return the results of operations, whilst the second is used to emit debugging information.
I'd like to only emit debug messages if and only if there is something actually connected to that port.
Internally, I'll probably be leaning heavily on NodeJS's EventEmitter
class, and for that, it has a listenerCount
method which tells me how many "listeners" have been connected to a given signal.
It'd be really nice if I could, in my node, say:
node.on("input", (msg, send, done) => {
let myobj = new MyObject();
if (node.getNumberOfConnectionsToOutputPort(1) > 0) {
myobj.on('debug', (debugmsg) => {
/* emit a debug message */
send([[], [debugmsg]]);
});
}
return myobj.doSomethingWith(msg, send).then(done).catch(done);
});
What I do not know, is what getNumberOfConnectionsToOutputPort
is actually called, or even if it exists.
Is there such a function? If so, where can I read up about it?