adding Future helper done method. Support undefined callbacks passed to Future.append...
authorLuc Yriarte <luc.yriarte@intel.com>
Fri, 24 May 2013 13:23:10 +0000 (15:23 +0200)
committerLuc Yriarte <luc.yriarte@intel.com>
Fri, 24 May 2013 13:23:10 +0000 (15:23 +0200)
cloudeebus/cloudeebus.js

index a288239..033d3a4 100644 (file)
@@ -256,8 +256,10 @@ cloudeebus.Future = function(init) {
 
 
 cloudeebus.Future.prototype.appendWrappers = function(acceptWrapper, rejectWrapper) {
-       this._acceptWrappers.push(acceptWrapper);
-       this._rejectWrappers.push(rejectWrapper);
+       if (acceptWrapper)
+               this._acceptWrappers.push(acceptWrapper);
+       if (rejectWrapper)
+               this._rejectWrappers.push(rejectWrapper);
        if (this.state == "accepted")
                _processWrappersAsync(this._acceptWrappers, this.result);
        if (this.state == "rejected")
@@ -310,6 +312,11 @@ cloudeebus.Future.prototype["catch"] = function(rejectCB) {
 };
 
 
+cloudeebus.Future.prototype.done = function(acceptCB, rejectCB) {
+       this.appendWrappers(acceptCB,rejectCB);
+};
+
+
 cloudeebus.Future.resolve = function(value) {
        var future = new cloudeebus.Future();
        future.resolver.resolve(value, true);