Вопрос по javascript, node.js – Как вы делитесь EventEmitter в node.js?

21

Error: User Rate Limit Exceeded

Error: User Rate Limit Exceeded

Ваш Ответ

3   ответа
15

var myModule = require('myModule')(Events)

module.exports = function(Events) {
    // Set up Event listeners here
}

Update:

Error: User Rate Limit Exceeded fancy
Error: User Rate Limit Exceeded fancy
Error: User Rate Limit ExceededemittersError: User Rate Limit Exceededexports.variable = new EventEmitter()Error: User Rate Limit ExceededrequireError: User Rate Limit ExceededemittersError: User Rate Limit Exceededvariable. fancy
Error: User Rate Limit Exceeded
Error: User Rate Limit Exceeded
12

process.on('customEvent', function(data) {
  ...
});

process.emit('customEvent', data);

.

Error: User Rate Limit Exceeded
Error: User Rate Limit Exceeded
Error: User Rate Limit Exceeded
Error: User Rate Limit Exceeded
Error: User Rate Limit Exceeded
18

Error: User Rate Limit Exceeded

eventBus.js:

const EventEmitter = require('events');
const emitter = new EventEmitter();

emitter.on('uncaughtException', function (err) {
    console.error(err);
});

module.exports = emitter;

Usage:

var bus = require('../path/to/eventBus');

// Register event listener
bus.on('eventName', function () {
    console.log('triggered!');
});

// Trigger the event somewhere else
bus.emit('eventName');
Error: User Rate Limit Exceeded

Похожие вопросы