Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/solarliner/promisify-html
Use promises for one-time bindings to Window/Document/Element events.
https://github.com/solarliner/promisify-html
document dom element event js promise window
Last synced: 19 days ago
JSON representation
Use promises for one-time bindings to Window/Document/Element events.
- Host: GitHub
- URL: https://github.com/solarliner/promisify-html
- Owner: SolarLiner
- License: mit
- Created: 2018-08-13T14:17:27.000Z (over 6 years ago)
- Default Branch: develop
- Last Pushed: 2018-08-13T15:58:15.000Z (over 6 years ago)
- Last Synced: 2024-11-01T00:42:59.632Z (2 months ago)
- Topics: document, dom, element, event, js, promise, window
- Language: TypeScript
- Size: 54.7 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# promisify-html
One-time binding to HTML events through promises.
## Install
```bash
npm install promisify-html
# OR
yarn add promisify-html
```## Use
To bind to a window, document or element event:
```javascript
// Bind to the window click event, printing the event object to the console
window.on("click").then((ev) => console.log(ev));
// Bind to document load event, printing the event object to the console
document.on("load").then((ev) => console.log(ev));
// Bind to an form's submit event, printing the event object to the console
const form = document.createElement("form");
form.on("submit").then((ev) => console.log(ev));
```Code uses the global `Promise` object, therefore you can use your favorite Promise library, as long as it implements the ES6 Promise constructor.