custom-event-emitter
v1.1.0
Published
A browser mixin that makes emitting CustomEvent objects really simple.
Downloads
3
Maintainers
Readme
custom-event-emitter
custom-event-emitter is a browser mixin that makes emitting CustomEvent objects really simple.
install
$ npm install custom-event-emitter
usage
var emitter = require('custom-event-emitter')
var element = document.createElement('p')
// Adds an emit function to the element.
// (the second argument is optional)
emitter.call(element, {
bubbles: true,
cancelable: true
})
element.addEventListener('hi', function(e) {
console.log(e.detail)
> 'how are you?'
})
element.emit('hi', 'how are you?')
You can run the above example like so:
$ npm run example