lazy-custom-event creates CustomEvent objects without all the ceremony.
$ npm install lazy-custom-event
var ce = require('lazy-custom-event')
var element = document.querySelector('p')
var greeting = ce('hi', 'how are you?', {
bubbles: true,
cancelable: true
})
element.addEventListener('hi', function(e) {
console.log(e.detail)
> 'how are you?'
})
element.dispatchEvent(greeting)
The only required argument is name
lazy-custom-event(
name,
[payload,]
[options]
)
$ git clone git@github.com:michaelrhodes/lazy-custom-event.git
$ cd lazy-custom-event
$ npm install && npm run test