# EventEmitter
Bling 使用了 eventemitter3,你可以通过 Bling.EventEmitter
获得,举个栗子:
const EE = new Bling.EventEmitter();
EE.on('event', () => {
console.log('an event occurred!');
});
EE.emit('event');
//=> an event occurred!
实例化的 EE 对象方法如下:
on(event, fn, context) // Add a listener for a given event.
off(event, fn, context, once) // Remove the listeners of a given event.
once(event, fn, context) // Add a one-time listener for a given event.
emit(event, a1, a2, a3, a4, a5) // Calls each of the listeners registered for a given event.
addListener(t,e,n) // Alias of method 'on'
removeListener(event, fn, context, once) // Alias of method 'off'
listeners(event, exists) // Return the listeners registered for a given event.
removeAllListeners(event) // Remove all listeners, or those of the specified event.
eventNames() // Return an array listing the events for which the emitter has registered listeners.