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

event-emitter-grouped

Package Overview
Dependencies
Maintainers
1
Versions
100
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

event-emitter-grouped

Emit events in serial or parallel with support for synchronous and asynchronous listeners

  • 2.3.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
394
decreased by-21.04%
Maintainers
1
Weekly downloads
 
Created
Source

Event Emitter Grouped

Build Status NPM version Gittip donate button Flattr donate button PayPayl donate button

Emit events in serial or parallel with support for synchronous and asynchronous listeners

Install

Node, Browserify

  • Use: require('event-emitter-grouped')
  • Install: npm install --save event-emitter-grouped

Ender

  • Use: require('event-emitter-grouped')
  • Install: ender add event-emitter-grouped

Component

  • Use: require('event-emitter-grouped')
  • Install: component install bevry/event-emitter-grouped

Bower

  • Use: require('event-emitter-grouped')
  • Install: bower install event-emitter-grouped

Usage

// Importer
var EventEmitterGrouped = require('event-emitter-grouped').EventEmitterGrouped;

// Instantiate a new instance
var emitter = new EventEmitterGrouped();

// Bind an asynchronous event
emitter.on('hello', function(next){
	console.log('\tasync started');
	setTimeout(function(){
		console.log('\tasync finished');
		next();
	}, 1000);
});

// Bind a synchronous event
emitter.on('hello', function(){
	console.log('\tsync started and finished');
});

// Bind a prioritized event
vipListener = function(){
	console.log('\tvip started and finished');
};
vipListener.priority = 1;
emitter.on('hello', vipListener);

// Emit the events in serial (one after the other in a waiting fashion)
console.log('hello in serial started');
emitter.emitSerial('hello', function(err){
	console.log('hello in serial finished');

	// Emit the events in parallel (all at once)
	console.log('hello in parallel started');
	emitter.emitParallel('hello', function(err){
		console.log('hello in parallel finished');
	});
});

/* Outputs:
hello in serial started
	vip started and finished
	async started
	async finished
	sync started and finished
hello in serial finished
hello in parallel started
	vip started and finished
	async started
	sync started and finished
	async finished
hello in parallel finished
*/

EventEmitterGrouped, extends events.EventEmitter

  • getListenerGroup(eventName, args..., next?) - returns a TaskGroup where each listener is a task, ordered by the highest priority listeners first
    • eventName is the event that we should get the listeners for
    • args... is an optional set of arguments that should be passed to the listeners when they are executed
    • next is an optional completion callback that will fire once all the tasks/listeners have compeleted
  • off - alias for events.EventEmitter.prototype.removeListener
  • emitSerial(eventName, args..., next?) - fetch the listener group and execute it in serial
  • emitParallel(eventName, args..., next?) - fetch the listener group and execute it in parallel

History

Discover the change history by heading on over to the History.md file.

Contribute

Discover how you can contribute by heading on over to the Contributing.md file.

Backers

Maintainers

These amazing people are maintaining this project:

Sponsors

No sponsors yet! Will you be the first?

Gittip donate button Flattr donate button PayPayl donate button

Contributors

These amazing people have contributed code to this project:

Become a contributor!

License

Licensed under the incredibly permissive MIT license

Copyright © 2013+ Bevry Pty Ltd us@bevry.me (http://bevry.me)
Copyright © 2011-2012 Benjamin Lupton b@lupton.cc (http://balupton.com)

Keywords

FAQs

Package last updated on 27 Oct 2013

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