lazy-custom-event

1.0.0 • Public • Published

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

Readme

Keywords

Package Sidebar

Install

npm i lazy-custom-event

Weekly Downloads

2

Version

1.0.0

License

MIT

Last publish

Collaborators

  • michaelrhodes