DOM
EventTarget
compatible events interface
$ npm install --save dom-event-target
var EventTarget = require('dom-event-target');
var target = new EventTarget()
target.addEventListener('myEvent', function (data) {
console.log('myEvent fired', data)
})
target.send('myEvent', {foo: 'bar'})
The true EventTarget
in the browser prevents the addition of duplicate handlers for an event. This library does not implement deduping. Duplicate handlers will be removed when removeEventListener
is called with matching arguments.
The useCapture
argument and the dispatchEvent
method are not implemented. dom-event-target provides an EventTarget API, not a full implementation of DOM events.
Creates a new EventTarget
Required
Type: string
The name of the event.
Required
Type: function
The event callback.
Required
Type: string
The name of the event.
Required
Type: function
The event callback.
send
is variadic and is called with the event name and arguments to be passed to the event callback
Required
Type: string
The name of the event.
MIT © Ben Drucker