Created
January 14, 2015 22:06
-
-
Save captainkovalsky/79af167b117ae4fe4dfd to your computer and use it in GitHub Desktop.
// source http://jsbin.com/vilocorore
This file contains 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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title>JS Bin</title> | |
</head> | |
<body> | |
<script id="jsbin-javascript"> | |
var objects = [ | |
{"id":1, "content":""}, | |
{"id":2, "content":""}, | |
{"id":3, "content":""} | |
]; | |
function deferredLoad(id, cb){ | |
setTimeout(function(){ | |
cb("content for " + id); | |
},4000); | |
objects.forEach(function(v, i, arr){ | |
deferredLoad(v.id, function(content){ | |
console.log('content : ', cotent); | |
//update content of object via closure I think | |
}); | |
}); | |
console.log(objects); | |
} | |
</script> | |
<script id="jsbin-source-javascript" type="text/javascript">var objects = [ | |
{"id":1, "content":""}, | |
{"id":2, "content":""}, | |
{"id":3, "content":""} | |
]; | |
function deferredLoad(id, cb){ | |
setTimeout(function(){ | |
cb("content for " + id); | |
},4000); | |
objects.forEach(function(v, i, arr){ | |
deferredLoad(v.id, function(content){ | |
console.log('content : ', cotent); | |
//update content of object via closure I think | |
}); | |
}); | |
console.log(objects); | |
}</script></body> | |
</html> |
This file contains 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
var objects = [ | |
{"id":1, "content":""}, | |
{"id":2, "content":""}, | |
{"id":3, "content":""} | |
]; | |
function deferredLoad(id, cb){ | |
setTimeout(function(){ | |
cb("content for " + id); | |
},4000); | |
objects.forEach(function(v, i, arr){ | |
deferredLoad(v.id, function(content){ | |
console.log('content : ', cotent); | |
//update content of object via closure I think | |
}); | |
}); | |
console.log(objects); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment