Skip to content

A type-safe toy implementation of Node.js Event Emitter.

License

Notifications You must be signed in to change notification settings

muttaqin1/eventEmitter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Node.js Event Emitter Hobby Project

This is a hobby project where I attempt to implement a simplified version of the Node.js Event Emitter functionality using Node.js and Typescript. Please note that this implementation is not intended for production use and serves solely as a learning exercise.

Description

The Node.js Event Emitter is a powerful tool in Node.js that allows objects to emit and listen to custom events. It provides a way to facilitate asynchronous communication between different components of an application. In this hobby project, I explore the basics of building an Event Emitter from scratch, aiming to gain a deeper understanding of its inner workings.

Features

  • Event Registration: You can register event listeners for specific events.
  • Event Emission: Emit events to trigger the execution of registered event listeners.
  • Support for Multiple Listeners: The implementation supports multiple listeners for the same event.

Usage

const EventEmitter = require('../dist/eventEmitter');

// Create an instance of the event emitter
const emitter = new EventEmitter();

// Register an event listener
emitter.on('customEvent', (data) => {
  console.log('Received data:', data);
});

// Emit an event
emitter.emit('customEvent', { message: 'Hello, world!' });

Contributions

Contributions to this hobby project are welcome! If you have ideas for improvements or new features, feel free to open an issue or submit a pull request.

License

This hobby project is licensed under the MIT License. For more information, please see the LICENSE file.

About

A type-safe toy implementation of Node.js Event Emitter.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published