javascript - Signal mechanism and event mechanism in Node.js ◔ ‸◔?
怪我咯
怪我咯 2017-05-16 13:43:18
0
1
602

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.');
})
怪我咯
怪我咯

走同样的路,发现不同的人生

reply all(1)
洪涛

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

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template