Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

component-emitter

Package Overview
Dependencies
Maintainers
33
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

component-emitter

Simple event emitter

  • 2.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
26M
increased by6.32%
Maintainers
33
Weekly downloads
 
Created

What is component-emitter?

The component-emitter package is a simple event emitter implementation that allows objects to subscribe to events, emit events, and remove event listeners. It is often used to add observer pattern capabilities to objects, enabling event-driven programming.

What are component-emitter's main functionalities?

Event subscription

This feature allows an object to listen for specific events using the 'on' method. When the event is emitted, the callback function is called.

const Emitter = require('component-emitter');
let emitter = new Emitter();
emitter.on('event', function(message) {
  console.log(message);
});

Event emission

This feature allows an object to emit an event, optionally passing arguments to the event listeners.

emitter.emit('event', 'Hello World!');

One-time event subscription

This feature allows an object to listen for an event only once. After the event is emitted and the listener is invoked, the listener is removed.

emitter.once('event', function(message) {
  console.log(message);
});

Event unsubscription

This feature allows an object to stop listening for specific events using the 'off' method.

function listener(message) {
  console.log(message);
}
emitter.on('event', listener);
emitter.off('event', listener);

Other packages similar to component-emitter

Keywords

FAQs

Package last updated on 17 Nov 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc