Skip to content

Instantly share code, notes, and snippets.

@kthompson
Created April 26, 2011 15:57
Show Gist options
  • Save kthompson/942535 to your computer and use it in GitHub Desktop.
Save kthompson/942535 to your computer and use it in GitHub Desktop.
Javascript Synchronous Caller
function SyncCall(method, errorCallback, successCallback)
{
var complete = false;
var retValue = null;
var errorCall = function(){
retValue = errorCallback();
complete = true;
}
var successCall = function(){
retValue = successCallback();
complete = true;
}
method(errorCall, successCall);
while(!complete) { };
return retValue;
}
@kthompson
Copy link
Author

might want to add a way to timeout

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment