Permalink
Browse files

Don't synchronously invoke the callbacks: wait, just as if the event …

…were delayed by the network
  • Loading branch information...
1 parent 7a3ad6a commit 7b93e5edfb78fd05e12fab0d50ddc006d1c14868 @tonyg committed Jun 8, 2012
Showing with 8 additions and 4 deletions.
  1. +8 −4 test/server_root/htdocs/jsonrpc.js
View
12 test/server_root/htdocs/jsonrpc.js
@@ -70,17 +70,21 @@ Object.extend(JsonRpcTransaction.prototype,
addCallback: function(cb) {
this.callbacks.push(cb);
if (this.replyReady) {
- try { cb(this.reply, false); }
- catch (err) {}
+ setTimeout(function () {
+ try { cb(this.reply, false); }
+ catch (err) {}
+ }, 0);
}
return this;
},
addErrorCallback: function(cb) {
this.errorCallbacks.push(cb);
if (this.error) {
- try { cb(this.error, true); }
- catch (err) {}
+ setTimeout(function () {
+ try { cb(this.error, true); }
+ catch (err) {}
+ }, 0);
}
return this;
}

0 comments on commit 7b93e5e

Please sign in to comment.