-
-
Save edwardhotchkiss/7897709 to your computer and use it in GitHub Desktop.
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 events = require('events'); | |
var b = require('./b'); | |
var emitter = module.exports = new events.EventEmitter(); | |
module.exports.init = function(callback) { | |
b.init(function() { | |
emitter.emit('done'); | |
}); | |
}; |
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 c = require('./c'); | |
module.exports.init = function(callback) { | |
c.init(callback); | |
}; |
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 a = require('./a'); | |
module.exports.init = function(callback) { | |
a.on('ready', function() { | |
console.log('"a" is now ready! (from c)'); | |
}); | |
callback(); | |
}; |
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 a = require('./a'); | |
a.on('ready', function() { | |
console.log('this a.on was able to be set'); | |
}); | |
a.init(function() { | |
console.log('finished main'); | |
}); |
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
test-circular$ node main.js | |
.../test-circular/c.js:5 | |
a.on('ready', function() { | |
^ | |
TypeError: Object #<Object> has no method 'on' | |
at Object.module.exports.init (.../test-circular/c.js:5:7) | |
at Object.module.exports.init (.../test-circular/b.js:5:7) | |
at EventEmitter.module.exports.init (.../test-circular/a.js:8:7) | |
at Object.<anonymous> (.../test-circular/main.js:8:3) | |
at Module._compile (module.js:456:26) | |
at Object.Module._extensions..js (module.js:474:10) | |
at Module.load (module.js:356:32) | |
at Function.Module._load (module.js:312:12) | |
at Function.Module.runMain (module.js:497:10) | |
at startup (node.js:119:16) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment