1.1.0 • Published 9 years ago

custom-event-emitter v1.1.0

Weekly downloads
2
License
MIT
Repository
github
Last release
9 years ago

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