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 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 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 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'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This problem seems to stay forever lol