mirror of
https://github.com/flynx/ImageGrid.git
synced 2025-12-26 13:01:58 +00:00
added a generic deffered queue...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
9c5b61ef22
commit
74876cf255
10
ui/files.js
10
ui/files.js
@ -716,13 +716,14 @@ function updateImagesOrientation(gids, no_update_loaded){
|
||||
//
|
||||
function updateImagesOrientationQ(gids, no_update_loaded){
|
||||
gids = gids == null ? getClosestGIDs() : gids
|
||||
//var res = []
|
||||
|
||||
var last = $.Deferred().resolve()
|
||||
|
||||
// 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()
|
||||
monitor.killed = false
|
||||
monitor.kill = function(){
|
||||
@ -732,12 +733,15 @@ function updateImagesOrientationQ(gids, no_update_loaded){
|
||||
$.each(gids, function(_, gid){
|
||||
var cur = $.Deferred()
|
||||
last.done(function(){
|
||||
// see if we are killed...
|
||||
if(monitor.killed == true){
|
||||
monitor.notify('killed')
|
||||
monitor.resolve()
|
||||
// this will kill the queue as we continue only on success...
|
||||
cur.reject()
|
||||
return
|
||||
}
|
||||
// do the work...
|
||||
updateImageOrientation(gid, no_update_loaded)
|
||||
.done(function(o){
|
||||
cur.resolve(o)
|
||||
@ -750,12 +754,8 @@ function updateImagesOrientationQ(gids, no_update_loaded){
|
||||
})
|
||||
|
||||
last = cur
|
||||
//res.push(cur)
|
||||
})
|
||||
|
||||
// NOTE: .when(...) is used to add more introspecitve feedback...
|
||||
//return $.when.apply(null, res)
|
||||
// return last
|
||||
last.done(function(){
|
||||
monitor.resolve()
|
||||
})
|
||||
|
||||
@ -678,23 +678,54 @@ function assyncCall(func){
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
function chainDeferreds(deferred, after){
|
||||
after = after == null ? $.Deferred.resolve() : after
|
||||
function makeDeferredsQ(){
|
||||
|
||||
$.each(deferred, function(_, d){
|
||||
var cur = $.Deferred()
|
||||
after.done(function(){
|
||||
d()
|
||||
.done(function(){ cur.resolve() })
|
||||
.fail(function(){ cur.reject() })
|
||||
})
|
||||
after = cur
|
||||
})
|
||||
var first = $.Deferred().resolve()
|
||||
var last = first
|
||||
|
||||
return after
|
||||
// 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()
|
||||
|
||||
monitor.kill = function(){
|
||||
this.resolve()
|
||||
}
|
||||
|
||||
monitor.enqueue = function(deffered){
|
||||
var cur = $.Deferred()
|
||||
last.done(function(){
|
||||
|
||||
// see if we are killed...
|
||||
if(monitor.state() == 'resolved'){
|
||||
// this will kill the queue as we continue only on success...
|
||||
cur.reject()
|
||||
return
|
||||
}
|
||||
|
||||
// do the work...
|
||||
deffered.apply(null, Array.apply(null, arguments).slice(1))
|
||||
.done(function(o){
|
||||
cur.resolve(o)
|
||||
monitor.notify('done')
|
||||
})
|
||||
.fail(function(){
|
||||
cur.resolve('fail')
|
||||
monitor.notify('fail')
|
||||
})
|
||||
})
|
||||
|
||||
last = cur
|
||||
}
|
||||
|
||||
monitor.start = function(){
|
||||
first.resolve()
|
||||
}
|
||||
|
||||
return monitor
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user