Effortlessly create CustomEvent instances.
Trigger events on any object that implements the EventTarget interface.
Fits well with Custom Elements in Web Components based apps.
Designed to be used with ECMAScript Function Bind syntax.
npm install --save bubbly
import {dispatch} from 'bubbly'
const target = new EventTarget()
target::dispatch('welcome', { hello: 'world' })
Like dispatch
but lets the event bubble up.
import {bubble} from 'bubbly'
document.body::bubble('shake', { dat: 'booty' })
Alias for addEventListener
.
import {on} from 'bubbly'
document::on('DOMContentLoaded', ::console.info)
Alias for removeEventListener
.
import {off} from 'bubbly'
document::off('DOMContentLoaded')
Wait for an event to fire, then stop listening.
import {once} from 'bubbly'
const anchor = document.createElement('a')
anchor::once('click', event => event.preventDefault())
Or treat an event like a Promise.
await anchor::once('click')
Run tests
npm test
TDD
mocha --watch