const e =newEvent();
e.add('sayHello',(err, name)=>{if(err){
console.error(err);return}
console.log(`hello ${name}`);return})
e.emit('sayHello','发生了错误');
e.emit('sayHello',null,'marron');
链式调用的实现
想使用如下的方式进行调用
const e =newEvent();
e
.add('sayHello',(err, name)=>{if(err){
console.error(err);return;}
console.log(`hello ${name}`);}).emit('sayHello','发生了错误').emit('sayHello',null,'mar~!');