Skip to content

Instantly share code, notes, and snippets.

@urstory
Created March 20, 2016 13:47
Show Gist options
  • Save urstory/b54a75e05228fbad4cba to your computer and use it in GitHub Desktop.
Save urstory/b54a75e05228fbad4cba to your computer and use it in GitHub Desktop.
function asynccall(jobFunction, successFunction, errorFunction, completeFunction){
setTimeout(function() {
try {
jobFunction();
} catch (err) {
errorFunction();
}
successFunction();
completeFunction();
}, 1 );
}
asynccall(
function(){
console.log('job!!!');
},
function(){
console.log('success!');
},
function(){
console.log('error!!');
},
function(){
console.log('complete');
}
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment