Skip to content

Commit

Permalink
Baby steps
Browse files Browse the repository at this point in the history
  • Loading branch information
briancavalier committed Jun 19, 2014
1 parent 2014d3e commit a447346
Show file tree
Hide file tree
Showing 7 changed files with 148 additions and 134 deletions.
2 changes: 1 addition & 1 deletion lib/decorators/flow.js
Expand Up @@ -20,7 +20,7 @@ define(function() {
* @returns {undefined}
*/
Promise.prototype.done = function(onResult, onError) {
this._handler.visit(onResult, onError);
this._handler.visit(this._handler.receiver, onResult, onError);
};

/**
Expand Down
2 changes: 1 addition & 1 deletion lib/decorators/fold.js
Expand Up @@ -10,7 +10,7 @@ define(function() {

Promise.prototype.fold = function(fn, arg) {
var promise = this._beget();
this._handler.fold(fn, arg, promise._handler);
this._handler.fold(fn, arg, void 0, promise._handler);
return promise;
};

Expand Down
9 changes: 5 additions & 4 deletions lib/decorators/timed.js
Expand Up @@ -19,9 +19,10 @@ define(function(require) {
var p = this._beget();
var h = p._handler;

this._handler.map(function delay(x) {
this._handler.visit(h, function delay(x) {
var h = this;
timer.set(function() { h.resolve(x); }, ms);
}, h);
}, h.reject, h.notify);

return p;
};
Expand All @@ -42,10 +43,10 @@ define(function(require) {

var t = timer.set(onTimeout, ms);

this._handler.chain(h,
this._handler.visit(h,
function onFulfill(x) {
timer.clear(t);
h.resolve(x); // this = p._handler
this.resolve(x); // this = p._handler
},
function onReject(x) {
timer.clear(t);
Expand Down

0 comments on commit a447346

Please sign in to comment.