search

Home  >  Q&A  >  body text

javascript - Signal mechanism and event mechanism in Node.js ◔ ‸◔?

I found that the signal mechanism used for inter-process 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.');
})
怪我咯怪我咯2746 days ago576

reply all(1)I'll reply

  • PHP中文网

    PHP中文网2017-05-16 13:45:18

    Essentially they are message mechanisms, which is a programming idiom.

    reply
    0
  • Cancelreply