Browse Source

Create a new file "eventEmitter.js" in the "src/services" directory, which exports a singleton instance of the EventEmitter for the entire application

node16
Onja 12 months ago
parent
commit
7213927988
  1. 15
      src/services/eventEmitter.js

15
src/services/eventEmitter.js

@ -0,0 +1,15 @@
// create a singleton instance of the EventEmitter for the entire application
const EventEmitter = require('events');
class MyEmitter extends EventEmitter {
static getInstance() {
if (!this.instance) {
this.instance = new MyEmitter();
}
return this.instance;
}
}
module.exports = MyEmitter.getInstance();
Loading…
Cancel
Save