lazy-custom-event
v1.0.0
Published
CustomEvent objects without all the ceremony.
Downloads
2
Readme
lazy-custom-event
lazy-custom-event creates CustomEvent objects without all the ceremony.
Install
$ npm install lazy-custom-event
Usage
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)
API
The only required argument is name
lazy-custom-event(
name,
[payload,]
[options]
)
Test
$ git clone [email protected]:michaelrhodes/lazy-custom-event.git
$ cd lazy-custom-event
$ npm install && npm run test