Skip to content

Instantly share code, notes, and snippets.

@Bioblaze
Created January 25, 2017 02:45
Show Gist options
  • Save Bioblaze/79196943515d7ba2c27f9e88f67150c8 to your computer and use it in GitHub Desktop.
Save Bioblaze/79196943515d7ba2c27f9e88f67150c8 to your computer and use it in GitHub Desktop.
One-way EventEmitter to Multiple Files
var Event = require('./Events').eventBus;
Events.on("test", function() {
console.log('it worked');
});
var util = require('util');
var eventEmitter = require('events').EventEmitter;
function Event () {
eventEmitter.call(this);
}
util.inherits(Event, eventEmitter);
var eventBus = new Event();
module.exports = {
emitter : Event,
eventBus : eventBus
};
var Event = require('./Events').eventBus;
Event.emit('test');
@Bioblaze
Copy link
Author

XD

I have a much better way to make this, I'll post it now.

@KaffinPX
Copy link

Thanks so much

@christo9090
Copy link

@Bioblaze did you ever post the alternate way to do this? tyty

@34Mx
Copy link

34Mx commented Jul 21, 2022

Thanks for it lol

This was so old, wow how did u even find this XD

This problem seems to stay forever lol

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment