-
-
Save ghostbar/bcc29ec190eeb616f571 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 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 |
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.js') | |
| function init () { | |
| a.on('init', function (string) { | |
| console.log('from b', string) | |
| }) | |
| } | |
| module.exports = init |
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.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