Last active
February 21, 2017 08:50
-
-
Save elliotthilaire/7fcaf6f918f06dc6b856cb1fa22b4d67 to your computer and use it in GitHub Desktop.
Playing with EventEmitter
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
const EventEmitter = require('events') | |
const myEmitter = new EventEmitter() | |
function start () { | |
myEmitter.emit('ready') | |
myEmitter.emit('set') | |
myEmitter.emit('go') | |
} | |
myEmitter.start = start | |
module.exports = myEmitter |
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 task = require('./task.js') | |
task.start() | |
task.on('ready', function (){ | |
}) | |
task.on('set', function () { | |
}) | |
task.on('go', function () { | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment