Skip to content

Instantly share code, notes, and snippets.

@Spaxe
Created August 31, 2015 23:55
Show Gist options
  • Save Spaxe/66f3e2f01aa20695254b to your computer and use it in GitHub Desktop.
Save Spaxe/66f3e2f01aa20695254b to your computer and use it in GitHub Desktop.
jQuery promise pseudo code
var i = 0;
function makeChartFromList(list) {
function consume ( data ) {
process(data);
i++;
if (i === list.length) {
$.Deferred().resolve();
} else {
makeChartFromList(list);
}
}
$.when(
$.ajax(list[i]), async: true
).done(consume);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment