1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
|
const EventEmitter = require('events');
const myEmitter = new EventEmitter();
function obs(...args){ console.log(args.join(',')); }
myEmitter.on('event',obs);
setTimeout(function() { myEmitter.emit('event',1,2,3) }, 1000);
myEmitter.removeListener('event',obs);
|