1.1.4 • Published 4 years ago
@superherocheesecake/event-dispatcher v1.1.4
EventDispatcher
Global EventDispatcher
NPM installation
npm i --save @superherocheesecake/event-dispatcherCommon practice
Most likely you will extend your own class.
import EventDispatcher from '@superherocheesecake/event-dispatcher';
class Module extends EventDispatcher {
// ...
}Methods
dispatchEvent(type, payload)
Payload can be any type of value.
this.dispatchEvent('eventName', {key: value});addEventListener(type, listener)
this.addEventListener('eventName', listener);addEventListenerOnce(type, listener)
this.addEventListenerOnce('eventName', listener);removeEventListener(type, listener)
this.removeEventListener('eventName', listener);hasEventListener(type, listener)
this.hasEventListener('eventName', listener);