Avoid crashes, improve response, yes its XML-RPC asynchronous

It appears the javascript stuff is still using jsolait's XML-RPC stuff
in synchronous mode a fair bit. This is the reason Firefox keeps
hanging (it doesn't deal well with XmlHttpRequest calls when they are
not asynch). Not wanting to nag, just wanted to make sure everyone was
aware of this... because its good stuff :-)

You can do an async call by appending a callback function to your
XML-RPC call. For example:

function callYarrr(someDiv, someArg) {
   returnVal = yarrr.remoteCall(someArg, blah);
   someDiv += "Remote call said: " + returnVal;

Is syncronous. It could be converted to async like so:

function callYarrr(someDiv, someArg) {
  var callback = new function(returnVal, error) {
    if (error != None) reportException(error);
    someDiv += "Remote call said: " + returnVal;
  yarrr.remoteCall(somearg, callback);

You can obviously call a "regular" function (i.e. not one dynamically
created using new) too, but this has the advantage that all the code
related to that operation is readable in one place, not hunt-n-search
to figure out where the "rest of the method" is after the async
returns. Also note that scoping is dynamic, so the callback function
should still have access to someDiv even though it won't be called
until callYarrr exits.

reportException() is defined by jsolait and will give a nice backtrace
for any jsolait generated exceptions (normal javascript exceptions
don't include the stack frame info).


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]