Last active
December 17, 2015 13:10
-
-
Save brianarn/5615467 to your computer and use it in GitHub Desktop.
Extended dojo/store/JsonRest with ability to mutate the server response
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
define([ | |
"dojo/_base/declare", | |
"dojo/store/JsonRest", | |
"dojo/store/util/QueryResults" | |
], function(declare, JsonRest, QueryResults){ | |
return declare(JsonRest, { | |
query: function(query, queryOptions){ | |
// Issue original query | |
var results = this.inherited(arguments); | |
// Using the promise-driven nature of queries, | |
// and then returning a promise, | |
// basically deref and provide the items, | |
// wrapped in the QueryResults API as store consumers expect | |
var itemsPromise = results.then(function(data){ | |
return data.items; | |
}); | |
return QueryResults(itemsPromise); | |
} | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment