Product
Introducing Java Support in Socket
We're excited to announce that Socket now supports the Java programming language.
The 'propagate' npm package is used to propagate events from one event emitter to another. This is particularly useful in scenarios where you want to forward events from one object to another seamlessly without manually emitting events from the second object.
Event Propagation
This feature allows you to forward all events from one EventEmitter to another. In the provided code, events from 'emitter1' are propagated to 'emitter2', so when 'emitter1' emits an 'event', 'emitter2' also handles and logs the event.
const EventEmitter = require('events');
const propagate = require('propagate');
let emitter1 = new EventEmitter();
let emitter2 = new EventEmitter();
// Propagate all events from emitter1 to emitter2
propagate(emitter1, emitter2);
emitter1.on('event', () => console.log('Handled by emitter1'));
emitter2.on('event', () => console.log('Handled by emitter2'));
emitter1.emit('event'); // Logs from both emitter1 and emitter2
EventEmitter2 is an implementation of EventEmitter with additional features like namespaces, wildcards, and timesToListen. It offers more flexibility and functionality compared to 'propagate' which mainly focuses on forwarding events.
EventEmitter3 is a high performance EventEmitter primarily focused on performance. While it does not offer direct event propagation like 'propagate', it is optimized for a high number of events and listeners, making it suitable for performance-critical applications.
Propagate events from one event emitter into another.
$ npm install propagate
var ee1 = new EventEmitter()
var ee2 = new EventEmitter()
propagate(ee1, ee2)
ee2.on('event', function(a, b) {
console.log('got propagated event', a, b)
})
ee1.emit('event', 'a', 'b')
You can unpropagate by ending the propagation like this:
var ee1 = new EventEmitter()
var ee2 = new EventEmitter()
var p = propagate(ee1, ee2)
// ...
p.end()
var ee1 = new EventEmitter()
var ee2 = new EventEmitter()
var p = propagate(['event1', 'event2'], ee1, ee2)
var ee1 = new EventEmitter()
var ee2 = new EventEmitter()
var p = propagate(
{
event1: 'other-event1',
event2: 'other-event2',
},
ee1,
ee2
)
MIT
FAQs
Propagate events from one event emitter into another
The npm package propagate receives a total of 3,279,134 weekly downloads. As such, propagate popularity was classified as popular.
We found that propagate demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?
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.
Product
We're excited to announce that Socket now supports the Java programming language.
Security News
Socket detected a malicious Python package impersonating a popular browser cookie library to steal passwords, screenshots, webcam images, and Discord tokens.
Security News
Deno 2.0 is now available with enhanced package management, full Node.js and npm compatibility, improved performance, and support for major JavaScript frameworks.