https://github.com/rupachowrasia/nodejs-event-emitter-for-pub-sub
A sample app to demostrate how node.js event emitters work
https://github.com/rupachowrasia/nodejs-event-emitter-for-pub-sub
emitter eventsemitter node-eventemitter node-events nodejs pubsub ticketing-system
Last synced: about 2 months ago
JSON representation
A sample app to demostrate how node.js event emitters work
- Host: GitHub
- URL: https://github.com/rupachowrasia/nodejs-event-emitter-for-pub-sub
- Owner: rupachowrasia
- Created: 2025-05-06T18:03:42.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-05-07T04:55:30.000Z (about 1 year ago)
- Last Synced: 2025-05-07T21:49:48.744Z (about 1 year ago)
- Topics: emitter, eventsemitter, node-eventemitter, node-events, nodejs, pubsub, ticketing-system
- Language: JavaScript
- Homepage:
- Size: 11.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Node.js Event Emitters
> In Node.js, the events module provides a way to implement event-driven architecture, where different parts of your application can communicate via emitting and listening to events.
## π§΅ When to Use
- Logging
- Messaging/event systems
- Async task management (e.g., background workers)
- Microservices event communication
- Streaming APIs
- Real-world use case - chat app, ticket system and logger
## π Key Methods
- emitter.on(): Adds an event listener
- emitter.emit(): Triggers an event
- emitter.once(): Listens only for the first occurrence
- emitter.removeListener() / off(): Removes a listener
- emitter.removeAllListeners(): Clears all listeners for a given event
## π¨ Tips
- Donβt forget to remove unused listeners to avoid memory leaks.
- You can increase the listener limit (default is 10):
## π Tech Stack
- Node.js
- Node.js events module
## π¦ Installation
```bash
# Clone the repo
git clone https://github.com/rupachowrasia/nodejs-event-emitter-for-pub-sub.git
# Move into the project directory
cd nodejs-event-emitter-for-pub-sub
# Install dependencies
npm install
# Run the app
npm run start