Skip to content

Commit

Permalink
support for full laziness when working with plain values.
Browse files Browse the repository at this point in the history
  • Loading branch information
swannodette committed Sep 4, 2009
1 parent d796ab2 commit 9a864a4
Showing 1 changed file with 7 additions and 13 deletions.
20 changes: 7 additions & 13 deletions Promises.js
Expand Up @@ -89,7 +89,7 @@ var Promise = new Class({
name: "Promise",

defaults: {
lazy: true,
lazy: false,
reduce: null,
bare: false,
meta: null
Expand Down Expand Up @@ -137,10 +137,6 @@ var Promise = new Class({
this.setValue(undefined);
this.fireEvent('error', this);
}.bind(this));
if(!this.options.lazy) {
if(Promise.debug) req.options.async = false;
req.send();
}
},

realize: function() {
Expand Down Expand Up @@ -199,13 +195,10 @@ var Promise = new Class({
return this.__value;
},

isRealized: function() {
return this.__realized;
},

isNotRealized: function() {
return !this.__realized;
},
isRealized: function() { return this.__realized; },
isNotRealized: function() { return !this.__realized; },
isLazy: function() { return this.options.lazy; },
isNotLazy: function() { return !this.options.lazy; },

get: function() {
var args = $A(arguments);
Expand All @@ -214,6 +207,7 @@ var Promise = new Class({
}
});
var $P = $promise = function(v, options) { return new Promise(v, options); };
var $lazy = function(v, options) { return new Promise(v, $merge({lazy:true}, options)); };

Promise.debug = false;

Expand Down Expand Up @@ -279,7 +273,7 @@ Promise.watch = function(args, cb, errCb) {
aPromise.addEvent('error', errCb.bind(null, [aPromise]));
});
}
unrealized.each($msg('realize'));
unrealized.filter($msg('isNotLazy')).each($msg('realize'));
} else {
cb(Promise.toValues(args))
}
Expand Down

0 comments on commit 9a864a4

Please sign in to comment.