Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

bubbly

Package Overview
Dependencies
Maintainers
3
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bubbly

Shorthand for event handling

  • 1.1.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
3
Created
Source

bubbly

Travis CI npm npm

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.

Installation

npm install --save bubbly

Usage

dispatch(type, detail)

import {dispatch} from 'bubbly'
const target = new EventTarget()
target::dispatch('welcome', { hello: 'world' })

bubble(type, detail)

Like dispatch but lets the event bubble up.

import {bubble} from 'bubbly'
document.body::bubble('shake', { dat: 'booty' })

on(type, handler)

Alias for addEventListener.

import {on} from 'bubbly'
document::on('DOMContentLoaded', ::console.info)

off(type, handler)

Alias for removeEventListener.

import {off} from 'bubbly'
document::off('DOMContentLoaded')

once(type, handler)

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')

Development

Run tests

npm test

TDD

mocha --watch

See Also

Keywords

FAQs

Package last updated on 20 Jul 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc