From 89a58abd7b691c0812f92a8bf7365c4428026a36 Mon Sep 17 00:00:00 2001 From: Rick Wong Date: Sat, 28 Mar 2015 15:42:13 +0100 Subject: [PATCH] Moved 1 then() handler into getAllQueries(). --- package.json | 2 +- src/lib/createContainer.js | 23 +++++++++++++---------- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/package.json b/package.json index c141ee9..550b8f4 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "react-transmit", "description": "Relay-inspired library based on Promises instead of GraphQL.", - "version": "2.2.0", + "version": "2.2.1", "license": "BSD-3", "repository": { "type": "git", diff --git a/src/lib/createContainer.js b/src/lib/createContainer.js index 8e48090..e8c24a9 100644 --- a/src/lib/createContainer.js +++ b/src/lib/createContainer.js @@ -50,7 +50,18 @@ module.exports = function (Component, options) { promises.push(Promise.resolve(true)); } - return Promise.all(promises); + return Promise.all(promises). + then(function (promisedQueries) { + var queryResults = {}; + + promisedQueries.forEach(function (promisedQuery) { + if (typeof promisedQuery === "object") { + assign(queryResults, promisedQuery); + } + }); + + return queryResults; + }); } }, componentWillMount: function () { @@ -72,15 +83,7 @@ module.exports = function (Component, options) { assign(_this.currentParams, nextParams); Container.getAllQueries(_this.currentParams). - then(function (promisedQueries) { - var queryResults = {}; - - promisedQueries.forEach(function (promisedQuery) { - if (typeof promisedQuery === "object") { - assign(queryResults, promisedQuery); - } - }); - + then(function (queryResults) { try { _this.setState(queryResults); }