Skip to content

Instantly share code, notes, and snippets.

@chadkouse
Created November 9, 2013 00:53
Show Gist options
  • Save chadkouse/7380014 to your computer and use it in GitHub Desktop.
Save chadkouse/7380014 to your computer and use it in GitHub Desktop.
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