Skip to content

Instantly share code, notes, and snippets.

@malintha
Last active June 7, 2016 05:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save malintha/f59b090872686980bc17ddf274f6ad0a to your computer and use it in GitHub Desktop.
Save malintha/f59b090872686980bc17ddf274f6ad0a to your computer and use it in GitHub Desktop.
firstFunctionCall : find([1,2], function(results) {
process(results, onMethodsDone);
});
callBackFunctionForProcess : function onMethodsDone(results1) {
alert("Results : "+results1);
}
alert("meanwhile I show up");
function process(elements, callback1) {
//The time consuming operation
setTimeout(function() {
elements.push(6,7,8);
callback1(elements);
}, 2000)
}
function find(elements, callback) {
//The time consuming operation
setTimeout(function() {
elements.push(3,4,5);
callback(elements);
} ,2000);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment