發(fā)現(xiàn)在 Node.js 中進程間通訊使用的訊號機制與事件機制十分相似(請參閱下方程式碼範例),這背後有什麼道理嗎?或是一種設(shè)計模式?
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.');
})
走同樣的路,發(fā)現(xiàn)不同的人生