Skip to content

Instantly share code, notes, and snippets.

@elliotthilaire
Last active February 21, 2017 08:50
Show Gist options
  • Save elliotthilaire/7fcaf6f918f06dc6b856cb1fa22b4d67 to your computer and use it in GitHub Desktop.
Save elliotthilaire/7fcaf6f918f06dc6b856cb1fa22b4d67 to your computer and use it in GitHub Desktop.
Playing with EventEmitter
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
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