1.0.0 • Published 9 years ago

lazy-custom-event v1.0.0

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

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 git@github.com:michaelrhodes/lazy-custom-event.git
$ cd lazy-custom-event
$ npm install && npm run test

license

MIT