1. onify
Futuristic Event Handler Registry
onify
Package: onify
Last modified: Wed, 22 Jun 2022 22:18:05 GMT
Version: 1.0.1
License: MIT
Downloads: 5

Install

npm install onify
yarn add onify

Futuristic Event Handler Registry


By futuristic I mean it doesn't work on old browsers and can't be transpiled so only use this if your target platforms all support Proxies.

Usage

import onify from 'onify'

onify(element)

// Register
element.on.mousedown = e=>console.log(`That was easy`)

// Clear
element.on.mousedown = null

Namespaces

Use namespaces just as easily.

element.on.spaced.mouseup = e=>console.log(`I'm namespaced!`)

Use as many as you want.

element.on.name.spaced.mouseup = e=>console.log(`I'm very namespaced!`)

Clearing

Setting a handler to a falsy value will clear that handler. But, you can also clear everything with the clear function.

// Clear everything in the "name" namespace and deeper
element.on.name.clear()

// Clear everything on the whole element
element.on.clear()

RELATED POST

Enhancing Vue.js Development: Harnessing the Potential of Vue-Loader

Enhancing Vue.js Development: Harnessing the Potential of Vue-Loader

Simplify Data Validation in Vue.js: A Step-by-Step Guide to Using Regex

Simplify Data Validation in Vue.js: A Step-by-Step Guide to Using Regex

Troubleshooting Made Easy: Common Issues and Solutions with vue-loader Without vue-cli

Troubleshooting Made Easy: Common Issues and Solutions with vue-loader Without vue-cli

Optimizing Webpack 4 with Vue CLI 3: Disabling the Cache-Loader

Optimizing Webpack 4 with Vue CLI 3: Disabling the Cache-Loader

Step-by-Step Guide: How to Add a Function to Your Vuex Plugin

Step-by-Step Guide: How to Add a Function to Your Vuex Plugin