Permalink
Browse files

get should work even if the promise is realized.

  • Loading branch information...
1 parent 80a2d72 commit 77872948f9c7061c89becd8f8f3caadf3206a9ca @swannodette swannodette committed Jul 31, 2009
Showing with 3 additions and 2 deletions.
  1. +3 −2 Promises.js
View
@@ -4,7 +4,7 @@
// ==/Builder==
/*
- Promises version 0.1
+ Promises version 0.4
An implementation of promises for MooTools:
http://en.wikipedia.org/wiki/Futures_and_promises
@@ -294,7 +294,8 @@ var Promise = new Class({
get: function()
{
var args = $A(arguments);
- return (new Promise(this.realize())).op(function(v) { return $get.apply(null, [v].extend(args)); });
+ if(!this.isRealized()) return (new Promise(this.realize())).op(function(v) { return $get.apply(null, [v].extend(args)); });
+ return $get.apply(null, [this.value()].extend(args));
}
});

0 comments on commit 7787294

Please sign in to comment.