Event Emitter
The tiny emitter the other packages share, published so you can share it too.
v0.1.0@magic-spells/event-emitter
Usage
import EventEmitter from '@magic-spells/event-emitter';
const emitter = new EventEmitter();
// Bind an event listener
emitter.on('greet', (name) => {
console.log(`Hello, ${name}!`);
});
// Trigger the event
emitter.emit('greet', 'World'); // Output: "Hello, World!"About
A lightweight, flexible event emitter utility for JavaScript applications. Provides a clean API for managing event listeners and triggering events with error handling.
Features
- ✨ Simple API - Easy to use event binding and triggering
- 🔧 Zero dependencies - Pure JavaScript implementation
- ⚡ Lightweight - Minimal footprint
- 🛡️ Error handling - Built-in error catching for event listeners
- 🔄 Method chaining - Fluent interface for easy composition
- 📦 Multiple formats - ESM, CommonJS, and UMD builds
About, features, usage and options are taken from the package README.