2021-06-30 16:56:57 +03:00
|
|
|
/**
|
|
|
|
* Why has this not been moved to e.g. @tryghost/events or shared yet?
|
|
|
|
*
|
|
|
|
* - We currently massively overuse this utility, coupling together bits of the codebase in unexpected ways
|
|
|
|
* - We want to prevent this, not reinforce it
|
|
|
|
* * Having an @tryghost/events or shared/events module would reinforce this bad patter of using the same event emitter everywhere
|
|
|
|
*
|
|
|
|
* - Ideally, we want to refactor to:
|
|
|
|
* - either remove dependence on events where we can
|
|
|
|
* - or have separate event emitters for e.g. model layer and routing layer
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2020-04-29 18:44:27 +03:00
|
|
|
const events = require('events');
|
|
|
|
const util = require('util');
|
|
|
|
let EventRegistry;
|
|
|
|
let EventRegistryInstance;
|
2015-03-24 23:23:23 +03:00
|
|
|
|
2016-04-10 03:20:56 +03:00
|
|
|
EventRegistry = function () {
|
|
|
|
events.EventEmitter.call(this);
|
|
|
|
};
|
2016-05-19 14:49:22 +03:00
|
|
|
|
2015-03-24 23:23:23 +03:00
|
|
|
util.inherits(EventRegistry, events.EventEmitter);
|
|
|
|
|
2015-10-09 21:27:49 +03:00
|
|
|
EventRegistryInstance = new EventRegistry();
|
|
|
|
EventRegistryInstance.setMaxListeners(100);
|
|
|
|
|
|
|
|
module.exports = EventRegistryInstance;
|