Socket
Socket
Sign inDemoInstall

@degjs/dom-event

Package Overview
Dependencies
0
Maintainers
8
Versions
1
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @degjs/dom-event

A Promise-based DOM event utility


Version published
Maintainers
8
Created

Readme

Source

DomEvent

DomEvent is a Promise-based event utility. Essentially, it wraps a Promise around a DOM event handler and resolves the Promise when the DOM event is triggered. This is especially useful when combined with other Promises to perform some action after all Promises have succeeded.

Install

DomEvent is an ES6 module. Consequently, you may need a transpiler (Babel is a nice one) to compile DomEvent into compatible Javascript for your runtime environment.

If you're using NPM, you can install DomEvent with the following command:

$ npm install @degjs/dom-event

Usage

import domEvent from '@degjs/dom-event';

const element = document.querySelector('.some-element');

/* Get a Promise for the transitionend event on an element */
const transitionPromise = domEvent(element, 'transitionend');

/* Get another Promise for some other asynchronous task, such as an API call */
const anotherPromise = someAsyncTask();

/* Perform some action when all promises succeed */
Promise.all([transitionPromise, anotherPromise])
			.then(onSuccessFunction)
			.catch(onErrorFunction);

Parameters

el

Type: Element
The DOM element that the DOM event will occur on.

eventName

Type: String
The DOM event that will trigger the Promise's success.

Browser Support

Breakpoints depends on the following browser APIs:

  • Promise

To support legacy browsers, you'll need to include polyfills for the above APIs.

Keywords

FAQs

Last updated on 20 Sep 2018

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc