Onja
1 year ago
1 changed files with 15 additions and 0 deletions
@ -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…
Reference in new issue