react-transporter
Advanced tools
Comparing version 0.5.6 to 0.5.7
@@ -7,6 +7,6 @@ 'use strict'; | ||
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); | ||
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; | ||
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); | ||
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; | ||
@@ -84,2 +84,11 @@ | ||
var getConfig = function getConfig(props) { | ||
// TODO memoize this function | ||
var tempConfig = makeConfig(props); | ||
return _extends({}, tempConfig, { | ||
loaders: tempConfig.loaders || {} | ||
}); | ||
}; | ||
var hasCodeSplit = component.name && component.bundle; | ||
@@ -100,3 +109,3 @@ var name = component.displayName || component.name || 'Component'; | ||
var config = _this.getConfig(); | ||
var config = getConfig(_this.props); | ||
var isPreload = _this.isPreload(); | ||
@@ -165,3 +174,3 @@ | ||
var config = this.getConfig(); | ||
var config = getConfig(this.props); | ||
var isPreload = this.isPreload(); | ||
@@ -205,3 +214,3 @@ | ||
var config = this.getConfig(); | ||
var config = getConfig(this.props); | ||
var isPreload = this.isPreload(); | ||
@@ -235,3 +244,3 @@ | ||
var config = this.getConfig(); | ||
var config = getConfig(nextProps); | ||
@@ -243,4 +252,4 @@ Object.keys(config.loaders).forEach(function (key) { | ||
// resource or not. | ||
if (loader.shouldUpdate && !_this4.state[key].loading) { | ||
if (loader.shouldUpdate({ | ||
if (loader.shouldReload && !_this4.state[key].loading) { | ||
if (loader.shouldReload({ | ||
info: _this4.state[key], | ||
@@ -326,12 +335,2 @@ cache: _this4.getCacheProvider() | ||
}, { | ||
key: 'getConfig', | ||
value: function getConfig() { | ||
// TODO memoize this function | ||
var tempConfig = makeConfig(this.props); | ||
return _extends({}, tempConfig, { | ||
loaders: tempConfig.loaders || {} | ||
}); | ||
} | ||
}, { | ||
key: 'isPreload', | ||
@@ -348,3 +347,3 @@ value: function isPreload() { | ||
var config = this.getConfig(); | ||
var config = getConfig(this.props); | ||
@@ -351,0 +350,0 @@ // Create loader props |
@@ -19,2 +19,24 @@ 'use strict'; | ||
var compareVariables = function compareVariables(a, b) { | ||
if (a && !b || !a && b) { | ||
return false; | ||
} | ||
if (a && b) { | ||
if (Object.keys(a).some(function (key) { | ||
return !b[key] || a[key] !== b[key]; | ||
})) { | ||
return false; | ||
} | ||
if (Object.keys(b).some(function (key) { | ||
return !a[key] || a[key] !== b[key]; | ||
})) { | ||
return false; | ||
} | ||
} | ||
return true; | ||
}; | ||
function query(schema) { | ||
@@ -30,3 +52,7 @@ var allOptions = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; | ||
request: function request(_ref, dispatch) { | ||
var load = _ref.load; | ||
var load = _ref.load, | ||
cache = _ref.cache; | ||
cache.set('variables', options.variables); | ||
return loaderOptions && loaderOptions.skip ? load(new Promise(function (resolve) { | ||
@@ -45,2 +71,4 @@ return resolve(); | ||
cache.set('variables', options.variables); | ||
return load(dispatch((0, _createQuery2.default)(schemaBody, _extends({}, options, localOptions)))); | ||
@@ -53,2 +81,4 @@ }, | ||
cache.set('variables', options.variables); | ||
return load(dispatch((0, _createQuery2.default)(schemaBody, _extends({}, options, localOptions)), { | ||
@@ -80,5 +110,6 @@ showWhileLoading: true | ||
return info.startTime < state.transporter.info.lastReset || previousVariables === options.variables; | ||
// Reload query if reset has been triggered or variables have changed | ||
return info.startTime < state.transporter.info.lastReset || !compareVariables(previousVariables, options.variables); | ||
} | ||
}; | ||
} |
{ | ||
"name": "react-transporter", | ||
"version": "0.5.6", | ||
"version": "0.5.7", | ||
"main": "./lib/index.js", | ||
@@ -5,0 +5,0 @@ "description": "React.js Redux GraphQL client", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
97776
2167