Skip to content

Commit

Permalink
Make addBoth API more like the one in twisted
Browse files Browse the repository at this point in the history
  • Loading branch information
Jc2k committed Mar 21, 2010
1 parent 47a7b30 commit 6e9c025
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions defer.js
Expand Up @@ -37,15 +37,21 @@ Deferred.prototype = {
this._processCallbacks ();
},

addCallback: function (callable, args) {
addCallback: function (callable) {
var args = Array.prototype.slice.call(arguments);
args.shift ();
this.addCallbacks (callable, args);
},

addErrback: function (callable, args) {
addErrback: function (callable) {
var args = Array.prototype.slice.call(arguments);
args.shift ();
this.addCallbacks (null, null, callable, args);
},

addBoth: function (callable, args) {
addBoth: function (callable) {
var args = Array.prototype.slice.call(arguments);
args.shift ();
// Add the same callable as a callback and an errback
this.addCallbacks(callable, args, callable, args);
},
Expand Down Expand Up @@ -118,7 +124,7 @@ function async (fn) {
try {
while (1) {
if (result instanceof Deferred) {
result.addBoth (process, [g, deferred]);
result.addBoth (process, g, deferred);
return deferred;
} else if (result instanceof Failure) {
g.throw (result);
Expand Down

0 comments on commit 6e9c025

Please sign in to comment.