Permalink
Browse files

breaks the Promise metaphor, unecessary as well

  • Loading branch information...
1 parent a44c68f commit 94a17829c1008dd596bcc89eec5fdc85caa1d852 @jobelenus committed Sep 30, 2011
Showing with 2 additions and 13 deletions.
  1. +2 −13 promise.handlebar.js
View
15 promise.handlebar.js
@@ -13,7 +13,7 @@
function engine() {
var publicAPI = function(cb) {
- var publicAPI, deferred = -999, queue = [], fail_queue = [], old_ret, promise_fulfilled = false, promise_failed = false;
+ var publicAPI, queue = [], fail_queue = [], old_ret, promise_fulfilled = false, promise_failed = false;
function fulfill(val) {
var ret_val = val;
@@ -28,8 +28,7 @@
ret_val = queue[0].call(publicAPI,ret_val);
- if (ret_val == deferred) { promise_fulfilled = false; promise_failed = false; }
- else if (typeof ret_val == "undefined") { ret_val = old_ret; }
+ if (typeof ret_val == "undefined") { ret_val = old_ret; }
else if (ret_val && !(ret_val instanceof Promise)) old_ret = ret_val;
queue.shift();
@@ -85,16 +84,6 @@
if (promise_failed) revoke(old_ret);
return publicAPI;
};
-
- publicAPI.fulfill = function(val) {
- if(promise_fulfilled)
- queue.shift(); // feels like i'm cheating
- promise_fulfilled = true
- fulfill.call(publicAPI, val);
- return publicAPI;
- };
-
- publicAPI.deferred = deferred;
if (cb == null) { // empty promise
promise_fulfilled = true;

0 comments on commit 94a1782

Please sign in to comment.