mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-07 01:57:50 +00:00
Add Jobs#reset.
This commit is contained in:
@@ -433,6 +433,25 @@ function Job(properties) {
|
|||||||
|
|
||||||
Job.prototype = _.create(EventEmitter.prototype);
|
Job.prototype = _.create(EventEmitter.prototype);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Resets the job.
|
||||||
|
*
|
||||||
|
* @memberOf Job
|
||||||
|
* @param {Function} callback The function called once the job is reset.
|
||||||
|
* @param {Object} Returns the job instance.
|
||||||
|
*/
|
||||||
|
Job.prototype.reset = function(callback) {
|
||||||
|
if (this.running) {
|
||||||
|
return this.stop(_.bind(this.reset, this));
|
||||||
|
}
|
||||||
|
this.attempts = 0;
|
||||||
|
this.failed = false;
|
||||||
|
this.id = this.result = this.url = null;
|
||||||
|
|
||||||
|
_.defer(callback);
|
||||||
|
return this;
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Restarts the job.
|
* Restarts the job.
|
||||||
*
|
*
|
||||||
@@ -580,11 +599,7 @@ function Tunnel(properties) {
|
|||||||
this.on('stop', function() {
|
this.on('stop', function() {
|
||||||
completed = 0;
|
completed = 0;
|
||||||
success = true;
|
success = true;
|
||||||
_.each(all, function(job) {
|
_.invoke(all, 'reset');
|
||||||
job.attempts = 0;
|
|
||||||
job.failed = false;
|
|
||||||
job.id = job.result = job.url = null;
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
this.jobs = {'active': active, 'all': all, 'queue': queue };
|
this.jobs = {'active': active, 'all': all, 'queue': queue };
|
||||||
|
|||||||
Reference in New Issue
Block a user