Created
April 26, 2011 15:57
-
-
Save kthompson/942535 to your computer and use it in GitHub Desktop.
Javascript Synchronous Caller
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
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; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
might want to add a way to timeout