Browse files

added description on lazy values.

  • Loading branch information...
swannodette committed Nov 16, 2009
1 parent 538c4e6 commit 5188ce11cb96084bc6171fe3f5610c578161768d
Showing with 22 additions and 1 deletion.
  1. +22 −1 readme.textile
@@ -476,4 +476,25 @@ if you changed something in doA that change would appear in doB because
you called doA first. However, using Promises is very much like writing code
with threads. You have no such guarantees.
-h2. Lazy Values
+h2. Lazy Values
+Sometimes it's very useful to be able to operate on values that don't actually
+exist yet. This is useful even when no remote request are involved. For example:
+var add = function(a, b) { return a + b; }.decorate(promise);
+var a = $lazy();
+var b = $lazy();
+var sum = add(a, b);
+sum.value(); // -> undefined
+sum.value(); // -> undefined
+sum.value(); // -> 5
+Pretty cool.
+Things get really interesting when you come to realize you can use this functionality
+with the DOM :)

0 comments on commit 5188ce1

Please sign in to comment.