先把代码放在这里,以后再更新
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')
先把代码放在这里,以后再更新
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')