How to use the eventemitter2.prototype 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 dshaw / socket.io-redis / lib / redis-store.js View on Github external
data = undefined;
    } else {
      try {
        data = JSON.parse(data);
      } catch (e) { /* then data is what it is */ }
    }
    console.log('redis subscriber', event, data);
    self.emit(event, data);
  });
}

/**
 * Monkey patch Socket.IO Store to use EventEmitter2 instead of events.EventEmitter
 */

Store.prototype.__proto__ = EventEmitter2.prototype;

/**
 * Inherits from Socket.IO Store
 */

util.inherits(RedisStore, Store);


/**
 * Namespaced keys.
 *
 * @param {String} key
 *
 * @api private
 */
github ditojs / dito / packages / server / src / lib / EventEmitter.js View on Github external
}

  once(event, callback) {
    return this._handle('once', event, callback)
  }

  static mixin(target) {
    Object.defineProperties(target, properties)
  }
}

const {
  constructor, // Don't extract constructor, but everything else
  ...properties
} = {
  ...Object.getOwnPropertyDescriptors(EventEmitter2.prototype),
  ...Object.getOwnPropertyDescriptors(EventEmitter.prototype)
}
github helion3 / inspire-tree / src / lib / events.js View on Github external
'use strict';

// Libs
var EventEmitter = require('eventemitter2');

function InspireEvents() {};
InspireEvents.prototype = Object.create(EventEmitter.prototype);

module.exports = InspireEvents;

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