custom-event-emitter

1.1.0 • Public • Published

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

license

MIT

Package Sidebar

Install

npm i custom-event-emitter

Weekly Downloads

1

Version

1.1.0

License

MIT

Last publish

Collaborators

  • michaelrhodes