nodejs emitter 小例子

先把代码放在这里,以后再更新

const events = require('events')
const emitter = new events.EventEmitter();

emitter.on('knock', () => {console.log('who is there')})
emitter.on('knock', () => {console.log('go away')})

emitter.emit('knock')

你可能感兴趣的:(nodejs emitter 小例子)