How to use the eventemitter3.prototype function in eventemitter3

To help you get started, we’ve selected a few eventemitter3 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 virtkick / http-master / src / HttpMasterWorker.js View on Github external
id = id.toString('base64');
      cb(null, store[id], null);
    },
    set: function(id, data, cb) {
      id = id.toString('base64');
      store[id] = data;
      // todo cleanup old ids
      if (cb)
        cb();
    }
  };
  this.tcpServers = {};
  this.servers = [];
}

HttpMasterWorker.prototype = Object.create(EventEmitter.prototype);

HttpMasterWorker.prototype.logNotice = function(msg) {
  this.emit('logNotice', msg);
};

HttpMasterWorker.prototype.logError = function(msg) {
  this.emit('logError', msg);
};

HttpMasterWorker.prototype.unbindAll = function(unbindFinished) {
  unbindAll.call(this, unbindFinished);
};

HttpMasterWorker.prototype.loadConfig = function(config, configLoaded) {
  var self = this;
github ninabreznik / voting-ethereum-contract / node_modules / web3-core-subscriptions / src / subscription.js View on Github external
EventEmitter.call(this);

    this.id = null;
    this.callback = null;
    this.arguments = null;
    this._reconnectIntervalId = null;

    this.options = {
        subscription: options.subscription,
        type: options.type,
        requestManager: options.requestManager
    };
}

// INHERIT
Subscription.prototype = Object.create(EventEmitter.prototype);
Subscription.prototype.constructor = Subscription;


/**
 * Should be used to extract callback from array of arguments. Modifies input param
 *
 * @method extractCallback
 * @param {Array} arguments
 * @return {Function|Null} callback, if exists
 */

Subscription.prototype._extractCallback = function (args) {
    if (_.isFunction(args[args.length - 1])) {
        return args.pop(); // modify the args array!
    }
};
github vanwagonet / middle-router / lib / router.js View on Github external
writable: true,
    value: fn
  }
}

function lazyLoad (step) {
  var self = this
  if (self.loaded) return self.fn(step)
  return Promise.resolve(self.fn(step)).then(function (fn) {
    if (fn instanceof Router) fn = middleRun(fn.middleware)
    self.loaded = true
    return (self.fn = fn)(step)
  })
}

Router.prototype = Object.create(EventEmitter.prototype, {

  start: method(function start () {
    if (this.isListening) this.stop() // remove previous listeners
    this.isListening = true
    this.unlisten = history.listen(this)
    return this.routing
  }),

  stop: method(function stop () {
    if (this.isListening) {
      this.isListening = false
      this.unlisten()
      this.unlisten = null
    }
    return this.routing
  }),
github klaytn / caver-js / packages / caver-core-subscriptions / src / subscription.js View on Github external
function Subscription(options) {
    EventEmitter.call(this)

    this.id = null
    this.callback = null
    this.arguments = null
    this._reconnectIntervalId = null

    this.options = {
        subscription: options.subscription,
        type: options.type,
        requestManager: options.requestManager,
    }
}

Subscription.prototype = Object.create(EventEmitter.prototype, {
    constructor: { value: Subscription },
})

/**
 * Should be used to extract callback from array of arguments. Modifies input param
 *
 * @method extractCallback
 * @param {Array} arguments
 * @return {Function|Null} callback, if exists
 */
Subscription.prototype._extractCallback = function(args) {
    if (_.isFunction(args[args.length - 1])) {
        return args.pop() // modify the args array!
    }
}
github lance-gg / sprocketleague / src / client / KeyboardControls.js View on Github external
constructor() {
        Object.assign(this, EventEmitter.prototype);

        this.setupListeners();

        // keep a reference for key press state
        this.activeInput = {
            down: false,
            up: false,
            left: false,
            right: false
        };
    }
github ethereum / web3.js / packages / web3-core-subscriptions / src / subscription.js View on Github external
EventEmitter.call(this);

    this.id = null;
    this.callback = _.identity;
    this.arguments = null;
    this._reconnectIntervalId = null;

    this.options = {
        subscription: options.subscription,
        type: options.type,
        requestManager: options.requestManager
    };
}

// INHERIT
Subscription.prototype = Object.create(EventEmitter.prototype);
Subscription.prototype.constructor = Subscription;


/**
 * Should be used to extract callback from array of arguments. Modifies input param
 *
 * @method extractCallback
 * @param {Array} arguments
 * @return {Function|Null} callback, if exists
 */

Subscription.prototype._extractCallback = function (args) {
    if (_.isFunction(args[args.length - 1])) {
        return args.pop(); // modify the args array!
    }
};
github GreyRook / gown.js / src / data / ListCollection.js View on Github external
* use the ListCollection functions to manipulate the data-array OR modify it
 * using the default array-functions and dispatch the CHANGED-Event yourself.
 *
 * @class ListCollection
 * @extends GOWN.ListCollection
 * @memberof GOWN
 * @constructor
 */
function ListCollection(data) {
    EventEmitter.call(this);
    if (!data) {
        data = [];
    }
    this.data = data;
}
ListCollection.prototype = Object.create( EventEmitter.prototype );
ListCollection.prototype.constructor = ListCollection;
module.exports = ListCollection;

ListCollection.CHANGED = 'changed';

ListCollection.RESET = 'reset';
ListCollection.REMOVE_ITEM = 'removeItem';
ListCollection.REPLACE_ITEM = 'replaceItem';
ListCollection.ADD_ITEM = 'addItem';

/**
 * The data source for this collection. Has to be an array.
 *
 * @property data
 * @type Object
 */
github pubfood / pubfood / dist / pubfood.js View on Github external
PubfoodEvent.prototype.on = function(event, fn) {
  var emitted = this.observeImmediate_[event] || null;
  if (emitted) {
    for (var i = 0; i < emitted.length; i++) {
      fn.apply(this, emitted[i]);
    }
    return this;
  }
  return EventEmitter.prototype.on.apply(this, arguments);
};
github pubfood / pubfood / src / event.js View on Github external
PubfoodEvent.prototype.removeAllListeners = function() {
  EventEmitter.prototype.removeAllListeners.call(this);

  this.observeImmediate_ = {};

  return this;
};
github wearesimbol / simbol-world / src / interactions / selection.js View on Github external
add(object) {
		const id = object.id;
		if (!this.objects[id]) {
			for (const property in EventEmitter.prototype) {
				object[property] = EventEmitter.prototype[property];
			}
			EventEmitter.call(object);
			this.objects[id] = object;
		}
	}

eventemitter3

EventEmitter3 focuses on performance while maintaining a Node.js AND browser compatible interface.

MIT
Latest version published 2 years ago

Package Health Score

79 / 100
Full package analysis