E
E
Egor2014-11-21 01:29:35
Node.js
Egor, 2014-11-21 01:29:35

How to make global eventEmitter in node.js server (express 4.x) ?

Greetings.
I want to make an eventEmitter that will be available in any module. What is the best way to organize it? Is there a 'best practice' for this case?
I 'm using express 4.x
PS tried this, didn't work:

var events = require('events');
global.eventEmitter = new events.EventEmitter();
global.eventEmitter.emit('testEvent');

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
Konstantin Kitmanov, 2014-11-21
@k12th

Best practice for express is app.locals .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question