react-esc-resolver
Advanced tools
Comparing version 4.0.0-beta.30 to 4.0.0-beta.31
@@ -71,14 +71,22 @@ 'use strict'; | ||
props = _props.props, | ||
cache = _props.cache; | ||
cache = _props.cache, | ||
cacheValidator = _props.cacheValidator; | ||
var cached = null; | ||
if (cache || !canUseDom()) { | ||
if (hasOwnProperty(props, resolve)) { | ||
return props[resolve]; | ||
cached = props[resolve]; | ||
} else if (this.context.resolver) { | ||
return this.context.resolver.cached(resolve); | ||
cached = this.context.resolver.cached(resolve); | ||
} | ||
} | ||
return null; | ||
console.log('has validator', cacheValidator && typeof cacheValidator === 'function'); | ||
if (cached && cacheValidator && typeof cacheValidator === 'function') { | ||
return cacheValidator(props); | ||
} | ||
return cached; | ||
} | ||
@@ -103,2 +111,4 @@ }, { | ||
value: function componentWillReceiveProps(nextProps) { | ||
console.log('componentWillReceiveProps'); | ||
var _computeState = this.computeState(nextProps, this.state), | ||
@@ -130,2 +140,4 @@ pending = _computeState.pending, | ||
console.log('cached', cached); | ||
if (!hasOwnProperty(state.resolved, name) && !hasOwnProperty(state.pending, name) && !_this2.isValidCache(cached)) { | ||
@@ -234,8 +246,6 @@ nextState.pending[name] = resolve[name]; | ||
var nextState = { | ||
_this3.setAtomicState({ | ||
pending: {}, | ||
resolved: _extends({}, state.resolved, resolved) | ||
}; | ||
_this3.setAtomicState(nextState); | ||
}); | ||
}); | ||
@@ -281,3 +291,4 @@ } | ||
props: {}, | ||
resolve: {} | ||
resolve: {}, | ||
cacheValidator: null | ||
}; | ||
@@ -288,3 +299,5 @@ Resolver.displayName = 'Resolver'; | ||
props: PropTypes.object, | ||
resolve: PropTypes.object | ||
resolve: PropTypes.object, | ||
cache: PropTypes.bool.isRequired, | ||
cacheValidator: PropTypes.func | ||
}; | ||
@@ -361,8 +374,13 @@ | ||
var cache = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true; | ||
var cacheValid = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null; | ||
var asyncProps = (typeof prop === 'undefined' ? 'undefined' : _typeof(prop)) === 'object' ? prop : _defineProperty({}, prop, promise); | ||
var asyncNames = _Object$keys(asyncProps).map(capitalize).join(''); | ||
var cacheEnabled = (typeof prop === 'undefined' ? 'undefined' : _typeof(prop)) === 'object' && typeof promise === 'boolean' ? promise : cache; | ||
var cacheEnabled = (typeof prop === 'undefined' ? 'undefined' : _typeof(prop)) === 'object' && typeof promise === 'boolean' ? promise : typeof cache === 'function' ? true : cache; | ||
var cacheValidator = typeof cache === 'function' ? cache : cacheValid; | ||
return function (Component) { | ||
@@ -385,3 +403,7 @@ var _class, _temp; | ||
Resolver, | ||
{ props: this.props, resolve: asyncProps, cache: cacheEnabled }, | ||
{ | ||
props: this.props, | ||
resolve: asyncProps, | ||
cache: cacheEnabled, | ||
cacheValidator: cacheValidator }, | ||
function (resolved) { | ||
@@ -388,0 +410,0 @@ return React.createElement(Component, resolved); |
@@ -74,4 +74,5 @@ 'use strict'; | ||
if (cache || !canUseDom()) { | ||
if (cache || !this[IS_CLIENT]) { | ||
if (hasOwnProperty(props, resolve)) { | ||
console.log(props[resolve]); | ||
return props[resolve]; | ||
@@ -129,6 +130,7 @@ } else if (this.context.resolver) { | ||
console.log('cached', cached); | ||
if (!hasOwnProperty(state.resolved, name) && !hasOwnProperty(state.pending, name) && !_this2.isValidCache(cached)) { | ||
nextState.pending[name] = resolve[name]; | ||
} else if (cached) { | ||
nextState.resolved[name] = true; | ||
nextState.resolved[name] = cached; | ||
} | ||
@@ -233,8 +235,6 @@ }); | ||
var nextState = { | ||
_this3.setAtomicState({ | ||
pending: {}, | ||
resolved: _extends({}, state.resolved, resolved) | ||
}; | ||
_this3.setAtomicState(nextState); | ||
}); | ||
}); | ||
@@ -241,0 +241,0 @@ } |
{ | ||
"name": "react-esc-resolver", | ||
"version": "4.0.0-beta.30", | ||
"version": "4.0.0-beta.31", | ||
"description": "Easy to use Client and Server Resolver", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
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
428208
829
1