Last active
April 6, 2016 09:01
-
-
Save shaikh-shahid/9f305f6956b3caafa3234741fbc2005c to your computer and use it in GitHub Desktop.
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 EventEmitter = require('events').EventEmitter; | |
var emitter = new EventEmitter(); | |
var fs = require('fs'); | |
// Event to read file - generic function. | |
emitter.on('start_read',function(file_name) { | |
console.log("Started Reading file....\n\n"); | |
fs.readFile(file_name, 'utf8', function (err,data) { | |
if (err) { | |
console.log("Error happens."); | |
} else { | |
console.log("File data", data); | |
} | |
}); | |
}); | |
// Let's read some file. | |
emitter.emit('start_read','env.json'); | |
emitter.emit('start_read','envConfig.js'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment