@aegisjsproject/callback-registry
v1.0.2
Published
A callback registry for AegisJSProject
Downloads
627
Maintainers
Readme
@aegisjsproject/callback-registry
A template repo for npm packages
A lightweight, modular JavaScript library for managing DOM events and callbacks. The library is designed for flexibility and efficiency, with a focus on leveraging modern JavaScript standards.
Features
- Callback Management: Centralized registration and retrieval of reusable callback functions.
- Event Handling: Simplified DOM event binding with support for custom attributes (e.g.,
data-aegis-event-on-*
). - Custom Events: Easily define and trigger application-specific events.
- Declarative Attributes: Leverages custom data attributes for declarative event configuration.
Installation
npm install @aegisjsproject/callback-registry
Example usage
import { createCallback, observeEvents, EVENTS } from '@aegisjsproject/callback-registry';
observeEvents();
const el = document.querySelector('.container');
el.setHTMLUnsafe(`<button ${EVENTS.onClick}="${createCallback(({ target }) => alert(target.innerHTML))}">Hello, World!</button>`);