Skip to content
This repository has been archived by the owner on Mar 15, 2018. It is now read-only.

Commit

Permalink
Added optionalQueryName argument to setQueryParams().
Browse files Browse the repository at this point in the history
  • Loading branch information
RickWong committed Apr 1, 2015
1 parent ce89dde commit 99ad8a1
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "react-transmit",
"description": "Relay-inspired library based on Promises instead of GraphQL.",
"version": "2.3.1",
"version": "2.3.2",
"license": "BSD-3",
"repository": {
"type": "git",
Expand Down
19 changes: 17 additions & 2 deletions src/lib/createContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,16 +75,31 @@ module.exports = function (Component, options) {
this.setQueryParams({});
}
},
setQueryParams: function (nextParams) {
setQueryParams: function (nextParams, optionalQueryName) {
var _this = this;

setTimeout(function () {
var state = _this.state || {};
var props = _this.props || {};
var promise;

assign(_this.currentParams, nextParams);

Container.getAllQueries(_this.currentParams).then(function (queryResults) {
if (optionalQueryName) {
promise = Container.getQuery(
optionalQueryName, _this.currentParams
).then(function (queryResult) {
var queryResults = {};
queryResults[optionalQueryName] = queryResult;

return queryResults;
});
}
else {
promise = Container.getAllQueries(_this.currentParams);
}

promise.then(function (queryResults) {
try {
_this.setState(queryResults);
}
Expand Down

0 comments on commit 99ad8a1

Please sign in to comment.