@dakinfosystems/events
v2.0.4
Published
eventJS enables script to emit event so that subscriber of that event will be notified.
Downloads
46
Readme
📦 EventJS
🚀 Why EventJS?
Most event emitters are:
- synchronous ❌
- non-extensible ❌
- lack scheduling ❌
EventJS solves that by combining:
- ⚡ Async + non-blocking execution
- 🧠 Smart scheduling
- 🔌 Middleware-style plugin system
- 📦 Batch processing
- 🎯 Predictable architecture
✨ Features
- Sync emit + async execution
- Microtask / macrotask / idle scheduling
- Plugin hooks (before/after emit & listener)
- Parallel & sequential dispatch
- Once listeners
- Strict mode validation
- Non-blocking queue
- TypeScript support
📥 Installation
npm install @dakinfosystems/events🧑💻 Quick Example
import { EventEmitter } from "@dakinfosystems/events";
const emitter = new EventEmitter();
emitter.registerEvent("greet");
emitter.on("greet", (name) => {
console.log("Hello", name);
});
emitter.emit("greet", "World");🔌 Plugin Example
emitter.use({
name: "logger",
beforeEmit(ctx) {
console.log("[Emit]", ctx.eventName);
},
afterListener(ctx) {
console.log("[Done]");
}
});🧠 Architecture
emit()
├── validation (sync)
├── beforeEmit (plugins)
├── queue
├── scheduler
├── dispatcher
│ ├── beforeListener
│ ├── handler
│ ├── afterListener
└── afterEmit⚙️ Configuration
new EventEmitter({
strictMode: true,
asyncMode: true,
strategy: "microtask",
batch: false
});🌐 CDN
<script src="https://cdn.jsdelivr.net/npm/@dakinfosystems/events@latest/dist/events.js"></script>🧪 Testing
pnpm test📦 Build
pnpm build🤝 Contributing
PRs welcome. Please include tests.
📄 License
MIT
