From 04a5b6a8ff1b36965afbc329105e9018ffdadece Mon Sep 17 00:00:00 2001 From: "Alex A. Naanou" Date: Thu, 11 Jul 2013 03:59:44 +0400 Subject: [PATCH] some cleanup... Signed-off-by: Alex A. Naanou --- ui/lib/jli.js | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/ui/lib/jli.js b/ui/lib/jli.js index 1c1aca5b..0880a64d 100755 --- a/ui/lib/jli.js +++ b/ui/lib/jli.js @@ -712,26 +712,22 @@ function makeDeferredsQ(first){ var last = first - // this is used for two things: - // - report progress - // - kill the queue if needed... - // XXX make this a deferred-like cleanly rather than bu monkey patching... - // XXX do we need to make this resumable?? - var monitor = $.Deferred() + // XXX make this a deferred-like cleanly, rather than by monkey patching... + var queue = $.Deferred() // Add a worker to queue... // // NOTE: .enqueue(...) accepts a worker and any number of the arguments // to be passed to the worker when it's its turn. // NOTE: the worker must porduce a deffered/promice. - monitor.enqueue = function(deffered){ + queue.enqueue = function(deffered){ var cur = $.Deferred() var args = Array.apply(null, arguments).slice(1) last.done(function(){ // see if we are killed... - if(monitor.state() == 'resolved'){ + if(queue.state() == 'resolved'){ // this will kill the queue as we continue only on success... cur.reject() return @@ -753,25 +749,28 @@ function makeDeferredsQ(first){ } // Start the work... - monitor.start = function(){ + queue.start = function(){ first.resolve() return this } + // Kill the queue... - monitor.kill = function(){ + queue.kill = function(){ this.resolve() return this } + + // Report work state... // XXX make this a propper state, or integrate into the deferred in // a more natural way... - monitor.isWorking = function(){ - if(monitor.state() != 'resolved' && last.state() != 'resolved'){ + queue.isWorking = function(){ + if(queue.state() != 'resolved' && last.state() != 'resolved'){ return true } return false } - return monitor + return queue }