javascript - Deferred Queue in Jquery with Phonegap -


i'm trying access db using phonegap sqlite , want create deferred queue.

how i'm trying access db follows

for(i=0,max=elem.length;i<max;i++) {    functiontoaccessdb(i); } 

i want make sure 1 call made db every time , others calls deferred till 1st 1 returns response.any insights ?

the sqliteplugin uses callback pattern opposed deferreds. need wrap in order use deferreds.

something might help:

var function functiontoaccessdbforpromise = function(i){     var d = $.deferred();     var successcallback = function(){         d.resolve(args);     };     var failcallback = function(){         d.reject(args);     };     functiontoaccessdbwithcallbacks(i,successcallback,failcallback)     return d.promise(); }; 

functiontoaccessdbforpromise return promise object can use queuing.


Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -