Last active
August 14, 2018 17:22
-
-
Save chaiwa-berian/8168e95870f3fcd39b154ec4f1a388e4 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
//We emit done and catch start events | |
var util = require('util'); | |
var Job = function Job(){ | |
//we will use it later to pass this to a closure | |
var job = this; | |
job.process = function(){ | |
//emulate the delay of a job async | |
setTimeout(function(){ | |
job.emit('done', {completedOn: new Date()}); | |
}, 700); | |
} | |
job.on('start',function(){ | |
job.process(); | |
}) | |
} | |
util.inherits(Job, require('events').EventEmitter); | |
module.exports = Job; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment