Created
November 9, 2013 00:53
-
-
Save chadkouse/7380014 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
loadObjectsFromArray: function (arr, finalCallback) { | |
var callbackCount = 0; | |
var embed = []; | |
var finishCallback = function () { | |
callbackCount++; | |
if (callbackCount >= arr.length) { | |
finalCallback(embed); | |
} | |
}; | |
for (var i = 0; i < arr.length; i++) { | |
(function () { | |
const idx = i; | |
var item = arr[i]; | |
var c = new MyDomain.MyObject(); | |
c.loadFromData(item, true, function (err, data) { | |
if (!err && data != null) { | |
embed[idx] = c; | |
} else { | |
embed[idx] = null; | |
} | |
finishCallback(); | |
}); | |
})(); | |
} | |
}, |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment