I want to run window.resolveLocalFileSystemURI(file,success,fail)
in for
loop passing different file entries and want to return resolved entries in array only after I get all the entries.
function resolveFiles(result,callback)
{
var resultData=[]
window.resolveLocalFileSystemURI(result, function(entry)
{
resolvedGalleryImages.push(entry);
callback(resolvedGalleryImages);
resolvedGalleryImages=[];
}, function(e)
{
alert("err"+e);});
}
//calling--
//@filesarr has captured images uris
for(i = 0; i < filesarr.length; i++)
{
resolveFiles(filesarr[i],function(result){
var resultArr = result;
});
}
How can I prevent callback to be called before I get all the entries.
this is all based on all your functions being synchronous, and if not: be more specific what you're using. (there is no jQuery here yet your tags say jquery)
There are multiple primary ways to attack a problem like this:
Here's the manual version:
And, here's a version that uses ES6 promises: