@aegisjsproject/callback-registry

1.0.2 • Public • Published

@aegisjsproject/callback-registry

A template repo for npm packages

CodeQL Node CI Lint Code Base

GitHub license GitHub last commit GitHub release GitHub Sponsors

npm node-current npm bundle size gzipped npm

GitHub followers GitHub forks GitHub stars Twitter Follow

Donate using Liberapay


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>`);

Package Sidebar

Install

npm i @aegisjsproject/callback-registry

Weekly Downloads

102

Version

1.0.2

License

MIT

Unpacked Size

151 kB

Total Files

11

Last publish

Collaborators

  • shgysk8zer0