Created
January 25, 2017 02:45
-
-
Save Bioblaze/79196943515d7ba2c27f9e88f67150c8 to your computer and use it in GitHub Desktop.
One-way EventEmitter to Multiple Files
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var Event = require('./Events').eventBus; | |
| Events.on("test", function() { | |
| console.log('it worked'); | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 | |
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var Event = require('./Events').eventBus; | |
| Event.emit('test'); |
Author
Thanks for it lol
This was so old, wow how did u even find this XD
XD
Author
XD
I have a much better way to make this, I'll post it now.
Thanks so much
@Bioblaze did you ever post the alternate way to do this? tyty
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
Thanks for it lol