Permalink
Browse files

* Promises.js: removed $lazy. $P & $promise now handle this if not gi…

…ve a value.
  • Loading branch information...
1 parent 7ca9d6f commit 4c3e79a92ce7a4e5e452e2c614564fa07642fe55 @swannodette swannodette committed Mar 24, 2010
Showing with 6 additions and 13 deletions.
  1. +4 −11 Promises.js
  2. +2 −2 readme.textile
View
@@ -36,7 +36,7 @@ Function.implement({
to false.
meta - Store some metadata about the promise. Useful fo debugging.
plain - The promise is a plain value. That is it is not a request. Not
- intended to be used directly. See $lazy.
+ intended to be used directly.
async - Make the promise realize synchronously. Defaults to false.
*/
var Promise = new Class({
@@ -96,6 +96,9 @@ var Promise = new Class({
// trigger a realized event.
this.__plain = true;
this.setValue(value, false);
+ } else if(typeof value == 'undefined') {
+ this.__plain = true;
+ this.options.lazy = true;
}
return this;
@@ -370,16 +373,6 @@ var Promise = new Class({
var $P = $promise = function(v, options) { return new Promise(v, options); };
/*
- Function: $lazy
- Creates Promises which can be uses as lazy values. See readme.textile
- for more details.
-
- Returns:
- A Promise instance with the lazy and plain options set to true.
-*/
-var $lazy = function(v, options) { return new Promise(v, $merge({lazy:true, plain:true}, options)); };
-
-/*
Constant: Promise.debug
Global flag for running Promises in debug mode. All promises will fetch
their remote data synchronously.
View
@@ -500,8 +500,8 @@ exist yet. This is useful even when no remote request are involved. For example:
<pre>
var add = function(a, b) { return a + b; }.decorate(promise);
-var a = $lazy();
-var b = $lazy();
+var a = $P();
+var b = $P();
var sum = add(a, b);
sum.value(); // -> undefined

0 comments on commit 4c3e79a

Please sign in to comment.