Permalink
Browse files

* Promises.js: added Promise.deref, don't assume data is the key retu…

…rned from a Request.
  • Loading branch information...
swannodette committed Mar 24, 2010
1 parent eabf991 commit 9d7df2883ae45aedb2d6520db28001ab14fda465
Showing with 2 additions and 1 deletion.
  1. +2 −1 Promises.js
View
@@ -138,7 +138,7 @@ var Promise = new Class({
this.__req = req;
req.addEvent('onSuccess', function(responseText) {
var json = (!req.options.bare) ? JSON.decode(responseText) : responseText,
- v = (json.data !== null && json.data !== undefined) ? json.data : json;
+ v = (Promise.deref !== null && json[Promise.deref] !== null && json[Promise.deref] !== undefined) ? json[Promise.deref] : json;
this.deliver(this.applyOps(v));
}.bind(this));
req.addEvent('onFailure', function(responseText) {
@@ -365,6 +365,7 @@ var Promise = new Class({
return fn(this.value());
}
});
+Promise.deref = 'data';
/*
Function: $P, $promise

0 comments on commit 9d7df28

Please sign in to comment.