Skip to content

Instantly share code, notes, and snippets.

@ghostbar
Last active January 31, 2016 05:19
Show Gist options
  • Save ghostbar/bcc29ec190eeb616f571 to your computer and use it in GitHub Desktop.
Save ghostbar/bcc29ec190eeb616f571 to your computer and use it in GitHub Desktop.
var ee = new (require('events').EventEmitter)()
function init () {
console.log('initialize this function on require')
setTimeout(function () {
ee.emit('init', 'got called!')
}, 2000)
}
init()
module.exports = ee
var a = require('./a.js')
function init () {
a.on('init', function (string) {
console.log('from b', string)
})
}
module.exports = init
var a = require('./a.js')
var b = require('./b.js')
console.log('this is index.js')
b()
a.on('init', function (string) {
console.log(string)
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment