
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
multi-event
Advanced tools
Simple event emitter that supports triggering listener to multiple events
npm install multi-event --save
require(["multi-event"], ...
var MultiEvent = require('multi-event'); // require it
var myEvents = new MultiEvent();
// Implement listener
var callBack = function (arg) {
console.log(arg);
};
// Register callBack event listener
myEvents.on('event', callBack);
myEvents.emit('event', 'this will be passed to the callback');
// shows 'this will be passed to the callback' in console
var MultiEvent = require('multi-event'); // require it
var myEvents = new MultiEvent();
var myEventsSubSet = new MultiEvent();
myEvents.pipe("event2.*", myEventsSubSet);
// Implement listener
var callBack1 = function (arg) {
console.log('callBack1 says : '+ arg);
};
var callBack2 = function (arg) {
console.log('callBack2 says : '+ arg);
};
var callBack = function (arg) {
console.log('callBack says : '+ arg);
};
var pipeCallBack = function (arg) {
console.log('pipeCallBack says : '+ arg + ' (from myEventsSubSet)');
};
// Register callBack event listener
myEvents.on('event.subevent1', callBack1)
.on('event.subevent2', callBack2)
.on('event.*', callBack); // this callBack is trigged to all 'event' sub-events
myEventsSubSet.on("event2.eventViaPipe", pipeCallBack);
myEvents.emit('event.subevent1', 'this string will be logged twice');
// the following will be displayed on the console
// callBack1 says : this string will be logged twice
// callBack says : this string will be logged twice
myEvents.emit('event.subevent2', 'this string will be logged twice');
// the following will be displayed on the console
// callBack2 says : this string will be logged twice
// callBack says : this string will be logged twice
myEvents.emit('event2.eventViaPipe', 'this will be passed to the other emitter also');
// the following will be displayed on the console
// pipeCallBack says : this will be passed to the other emitter also (from myEventsSubSet)
This module is writen in ES6, you can find the in src/multi-event-es6.js
For building your modification run npm run build
, the files multi-event.js
and multi-event.min.js
are created in dist
folder
npm run build
npm run test
npm run watch
FAQs
Simple event emitter that supports triggering listener to multiple events
We found that multi-event demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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.
Security News
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.