How to use the eventemitter2.EventEmitter2 function in eventemitter2

To help you get started, we’ve selected a few eventemitter2 examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github noseglid / atom-build / spec / fixture / node_modules / grunt / lib / grunt / event.js View on Github external
/*
 * grunt
 * http://gruntjs.com/
 *
 * Copyright (c) 2014 "Cowboy" Ben Alman
 * Licensed under the MIT license.
 * https://github.com/gruntjs/grunt/blob/master/LICENSE-MIT
 */

'use strict';

// External lib.
var EventEmitter2 = require('eventemitter2').EventEmitter2;

// Awesome.
module.exports = new EventEmitter2({wildcard: true});
github joecritch / container-queries / node_modules / grunt / lib / grunt / event.js View on Github external
/*
 * grunt
 * http://gruntjs.com/
 *
 * Copyright (c) 2013 "Cowboy" Ben Alman
 * Licensed under the MIT license.
 * https://github.com/gruntjs/grunt/blob/master/LICENSE-MIT
 */

'use strict';

// External lib.
var EventEmitter2 = require('eventemitter2').EventEmitter2;

// Awesome.
module.exports = new EventEmitter2({wildcard: true});
github daviddias / webrtc-explorer / modules / chord.js View on Github external
function node(config) {
  localStorage.debug = config.logging || false;
  // t = canela.createTracer({emitter: ee, active: config.tracing || false});

  var id = uuid.gen();                  // our node id
  // var fingers = fingerTable.create(id); // create our nitty finger table
  var predecessor;
  var sucessor;                       
  var emitter = new eventEmitter2({ wildcard: true, newListener: false, maxListeners: 80 });

  /// Joining the Chord network through Signaling procedures

  var url = (config.signalingURL || 'http://default.url') + (config.namespace || '/');
  var ioClient = io(url);
  ioClient.on('connect', join);
  
  // warmup mode join
  ioClient.on('c-warmup-predecessor', acceptPredecessor);
  ioClient.on('c-warmup-sucessor', acceptSucessor);

  // normal mode join/rail new node
  ioClient.on('c-response', joinResponse);
  ioClient.on('c-predecessor', newPredecessor);
  ioClient.on('c-sucessor', newSucessor);
github tinkerhub / tinkerhub / lib / net / tcp.js View on Github external
constructor(transport) {
		this.transport = transport;
		this.events = new EventEmitter2();

		// Reply to hello messages with our metadata
		this.events.on('hello', msg => {
			this.id = msg.id;
			this.version = msg.version;

			this.write('metadata', {
				id: this.transport.id,
				version: 1
			});
		});
	}
github primus / eventemitter3 / benchmarks / run / once.js View on Github external
var EventEmitter2 = require('eventemitter2').EventEmitter2
  , EventEmitter1 = require('events').EventEmitter
  , EventEmitter3 = require('eventemitter3')
  , Drip = require('drip').EventEmitter
  , CE = require('contra/emitter')
  , EE = require('event-emitter')
  , FE = require('fastemitter')
  , Master = require('../../');

function handle() {
  if (arguments.length > 100) console.log('damn');
}

var ee1 = new EventEmitter1()
  , ee2 = new EventEmitter2()
  , ee3 = new EventEmitter3()
  , master = new Master()
  , drip = new Drip()
  , fe = new FE()
  , ce = CE()
  , ee = EE();

(
  new benchmark.Suite()
).add('EventEmitter1', function() {
  ee1.once('foo', handle).emit('foo');
}).add('EventEmitter2', function() {
  ee2.once('foo', handle).emit('foo');
}).add('EventEmitter3@0.1.6', function() {
  ee3.once('foo', handle).emit('foo');
}).add('EventEmitter3(master)', function() {
github angular / batarang / dist / hint.js View on Github external
},{"../lib/event-directives":4}],23:[function(require,module,exports){
'use strict';

/**
 * We use EventEmitter2 here in order to have scoped events
 * For instance:
 *    hint.emit('scope:digest', {
 */
var EventEmitter2 = require('eventemitter2').EventEmitter2;

angular.hint = new EventEmitter2({
  wildcard: true,
  delimiter: ':'
});
},{"eventemitter2":27}],24:[function(require,module,exports){
'use strict';
github physiii / open-automation / server / services / service.js View on Github external
constructor (data, onUpdate, deviceOn, deviceEmit, save) {
		this.id = data.id || uuidV4();
		this.type = this.constructor.type || data.type;
		this.device_id = data.device_id;

		this.events = new EventEmitter2({wildcard: true, newListener: false, maxListeners: 0});
		this.deviceOn = (event, callback) => deviceOn(event, callback, this.id, this.type);
		this.deviceEmit = (event, data, callback) => deviceEmit(event, data, callback, this.id, this.type);
		this.onUpdate = onUpdate;

		try {
			this.state_definitions = new Map(data.state_definitions);
		} catch (error) {
			this.state_definitions = new Map(...this.constructor.state_definitions);
		}

		this.settings = new DeviceSettings(
			data.settings,
			data.settings_definitions,
			this.constructor.settings_definitions,
			this.deviceEmit,
			save
github daviddias / webrtc-explorer / src / lib / peer.js View on Github external
function Peer(config) {
    localStorage.debug = config.logging || false;
    var self = this;

    self.events = new ee2({
        wildcard: true,
        newListener: false,
        maxListeners: 20 
    });

    var ioc = io(config.signalingURL + '/');

    ioc.once('connect', connected);
    ioc.on('c-finger-update', function(data) {
        if (!self.fingerTable) {
            log('DEBUG: got a finger-update before finger table was ready');
        }

        self.fingerTable.fingerUpdate(data);
    });
github frctl / fractalite / packages / support / emitter.js View on Github external
constructor(emitter) {
    this._emitter = emitter || new EventEmitter2({ wildcard: true });
  }
github bigbluebutton / bigbluebutton / bigbluebutton-html5 / imports / startup / server / redis2x.js View on Github external
constructor(config = {}) {
    this.config = config;

    this.didSendRequestEvent = false;
    this.pub = Redis.createClient();
    this.sub = Redis.createClient();
    this.emitter = new EventEmitter2();
    this.queue = new PowerQueue();

    this.handleTask = this.handleTask.bind(this);
    this.handleSubscribe = this.handleSubscribe.bind(this);
    this.handleMessage = this.handleMessage.bind(this);
  }

eventemitter2

A feature-rich Node.js event emitter implementation with namespaces, wildcards, TTL, async listeners and browser/worker support.

MIT
Latest version published 2 years ago

Package Health Score

79 / 100
Full package analysis