It is found that the signaling mechanism used for interprocess communication in Node.js is very similar to the event mechanism (see the code example below). Is there any reason behind this? Or a design pattern?
signal
child.kill('SIGUSR1');
process.on('SIGUSR1', function () {
console.log('Got a SIGUSR1 signal.');
})
event
eventEmitter.emit('event')
eventEmitter.on('event', function () {
console.log('Trigger an event.');
})
It is essentially a message mechanism, which is a common programming method.