How to use the eventemitter2.EventEmitter2.call 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 christianalfoni / flux-angular / release / flux-angular.js View on Github external
var Store = function (dispatcher) {
    this.dispatcher = dispatcher;

    // Check if store exists when waiting for it
    this.waitFor = function (stores, cb) {
      stores = Array.isArray(stores) ? stores : [stores];
      if (!flux.isStoresRegistered(stores)) {
        throw new Error('Waiting for stores that are not injected into Angular yet, ' + stores.join(', ') + '. Be sure to inject stores before waiting for them');
      }
      this.dispatcher.waitFor(stores, cb.bind(this));
    };

    // Call the constructor of EventEmitter2
    EventEmitter2.call(this, {
      wildcard: true
    });

    if (typeof maxListeners === 'number') {
      this.setMaxListeners(maxListeners);
    } else if (maxListeners && typeof maxListeners[name] === 'number') {
      this.setMaxListeners(maxListeners[name]);
    }

    if (this.initialize) {
      this.initialize();
    }
  };
github FGRibreau / node-children / lib / Children.js View on Github external
function Children(workerPath, options) {
  if (!(this instanceof Children)) {
    return new Children(workerPath, options);
  }

  EventEmitter2.call(this, {
    wildcard: false
  });

  this.options = _.defaults(options || {}, Children.defaults);
  this.options.workerPath = workerPath;

  if (!this.options.resetEnv) {
    this.options.spawn_options.env = process.env;
  }

  // Children array
  this.childs = [];
  this._shuttingDown = false;

  if (this.options.autoRestart) {
    this.on('killed:child', this._autorespawn.bind(this));
github documark / documark / lib / document.js View on Github external
function Document (documentFile) {
	this._file    = null;
	this._path    = null;
	this._config  = null;
	this._content = null;
	this._plugins = [];
	this._debug   = 0;

	if (documentFile) {
		this.file(documentFile);
	}

	// Make class an event emitter
	EventEmitter.call(this);

	this.setMaxListeners(100);
}
github BitMEX / api-connectors / official-ws / nodejs / index.js View on Github external
function BitMEXClient(options) {
  const emitter = this;
  // We inherit from EventEmitter2, which supports wildcards.
  EventEmitter.call(emitter, {
    wildcard: true,
    delimiter: ':',
    maxListeners: Infinity,
    newListener: true,
  });
  if (!options) options = {};
  this._data = {}; // internal data store keyed by [tableName][symbol]. Used by deltaParser.
  this._keys = {}; // keys store - populated by images on connect
  this._maxTableLen = typeof options.maxTableLen === 'number' ? options.maxTableLen : DEFAULT_MAX_TABLE_LEN;
  if (!options.endpoint) {
    options.endpoint = options.testnet ? endpoints.testnet : endpoints.production;
  }
  if (process.env.BITMEX_ENDPOINT) options.endpoint = process.env.BITMEX_ENDPOINT;
  debug(options)

  this._setupListenerTracking();
github GitbookIO / repofs / lib / working.js View on Github external
function WorkingTree(store, branch) {
    EventEmitter.call(this, {
        wildcard: true
    });

    this.store = store;
    this.currentBranch = branch;

    _.bindAll(this);
}
util.inherits(WorkingTree, EventEmitter);
github foreversd / nssocket / lib-cov / nssocket.js View on Github external
_$jscoverage['nssocket.js'][39]++;
    return new NsSocket(options, socket);
  }
  _$jscoverage['nssocket.js'][42]++;
  if (! options) {
    _$jscoverage['nssocket.js'][43]++;
    options = socket || {};
  }
  _$jscoverage['nssocket.js'][46]++;
  this.connected = false;
  _$jscoverage['nssocket.js'][47]++;
  this.type = options.type || "tcp4";
  _$jscoverage['nssocket.js'][48]++;
  this.retry = options.reconnect? {retries: 0, max: options.maxRetries || 10, wait: options.retryInterval || 5000, timeoutId: undefined}: false;
  _$jscoverage['nssocket.js'][55]++;
  EventEmitter2.call(this, {delimiter: options.delimiter || "::", wildcard: true, maxListeners: options.maxListeners || 10});
  _$jscoverage['nssocket.js'][61]++;
  if (socket) {
    _$jscoverage['nssocket.js'][62]++;
    this.stream = socket;
    _$jscoverage['nssocket.js'][63]++;
    this.socket = this.stream instanceof net.Socket? this.stream: this.stream.socket;
    _$jscoverage['nssocket.js'][64]++;
    this.connected = this.socket.writable && this.socket.readable || false;
    _$jscoverage['nssocket.js'][65]++;
    configureEvents(this);
  }
}
_$jscoverage['nssocket.js'][69]++;
github ContentMine / thresher / lib / thresher.js View on Github external
var Thresher = function(scraperBox) {
  this.scraperBox = scraperBox;
  EventEmitter2.call(this, {
    wildcard: true,
    maxListeners: 0
  });
}
github gruntjs / grunt-next / runner / index.js View on Github external
function Grunt (env) {
  this.env = env;
  this.events = this;
  this.tasks = [];
  this.option = expander.interface(this.env.argv);
  EventEmitter2.call(this, {wildcard:true});
  bindMany(['loadTasks', 'loadNpmTasks'], this);
  legacy(this);
}
util.inherits(Grunt, EventEmitter2);
github yui / yeti / lib / blizzard / namespace.js View on Github external
function BlizzardNamespace(session, ns) {
    this.session = session;
    this.ns = ns;

    EventEmitter2.call(this, {
        wildcard: true
    });

    this.rpcListener = null;

    this.sessionRequestEvent = null;
    this.sessionRequestListener = null;

    this.bound = false;

    this.bind();
}

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

82 / 100
Full package analysis