async-reactor
Advanced tools
Comparing version 1.0.2 to 1.0.3
@@ -1,1 +0,1 @@ | ||
'use strict';var _createClass=function(){function defineProperties(target,props){for(var descriptor,i=0;i<props.length;i++)descriptor=props[i],descriptor.enumerable=descriptor.enumerable||!1,descriptor.configurable=!0,'value'in descriptor&&(descriptor.writable=!0),Object.defineProperty(target,descriptor.key,descriptor)}return function(Constructor,protoProps,staticProps){return protoProps&&defineProperties(Constructor.prototype,protoProps),staticProps&&defineProperties(Constructor,staticProps),Constructor}}();exports.__esModule=!0,exports.Reactactor=void 0;exports.asyncReactor=asyncReactor;var _react=require('react');function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor))throw new TypeError('Cannot call a class as a function')}function _possibleConstructorReturn(self,call){if(!self)throw new ReferenceError('this hasn\'t been initialised - super() hasn\'t been called');return call&&('object'==typeof call||'function'==typeof call)?call:self}function _inherits(subClass,superClass){if('function'!=typeof superClass&&null!==superClass)throw new TypeError('Super expression must either be null or a function, not '+typeof superClass);subClass.prototype=Object.create(superClass&&superClass.prototype,{constructor:{value:subClass,enumerable:!1,writable:!0,configurable:!0}}),superClass&&(Object.setPrototypeOf?Object.setPrototypeOf(subClass,superClass):subClass.__proto__=superClass)}function isFunction(p){return'function'==typeof p}function isPromise(){var p=0<arguments.length&&arguments[0]!==void 0?arguments[0]:{};return isFunction(p.then)}var Reactactor=exports.Reactactor=function(_Component){function Reactactor(props){_classCallCheck(this,Reactactor);var _this=_possibleConstructorReturn(this,(Reactactor.__proto__||Object.getPrototypeOf(Reactactor)).call(this,props));_this.state={};var promise=_this.props.wait(_this.props.passthroughProps);if(!isPromise(promise))throw new Error('you must provide an async component');return _this._promise=promise,_this}return _inherits(Reactactor,_Component),_createClass(Reactactor,[{key:'componentWillMount',value:function componentWillMount(){var _this2=this;this._promise.then(function(data){_this2.setState({data:data})}).catch(function(err){throw err})}},{key:'render',value:function render(){return this.state.data?this.state.data:null}}]),Reactactor}(_react.Component);function asyncReactor(component){if(!isFunction(component))throw new Error('you must provide an async component');return function(){var passthroughProps=0<arguments.length&&arguments[0]!==void 0?arguments[0]:{};return(0,_react.createElement)(Reactactor,{wait:component,passthroughProps:passthroughProps})}} | ||
'use strict';var _createClass=function(){function defineProperties(target,props){for(var descriptor,i=0;i<props.length;i++)descriptor=props[i],descriptor.enumerable=descriptor.enumerable||!1,descriptor.configurable=!0,'value'in descriptor&&(descriptor.writable=!0),Object.defineProperty(target,descriptor.key,descriptor)}return function(Constructor,protoProps,staticProps){return protoProps&&defineProperties(Constructor.prototype,protoProps),staticProps&&defineProperties(Constructor,staticProps),Constructor}}();exports.__esModule=!0,exports.Reactactor=void 0;exports.asyncReactor=asyncReactor;var _react=require('react');function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor))throw new TypeError('Cannot call a class as a function')}function _possibleConstructorReturn(self,call){if(!self)throw new ReferenceError('this hasn\'t been initialised - super() hasn\'t been called');return call&&('object'==typeof call||'function'==typeof call)?call:self}function _inherits(subClass,superClass){if('function'!=typeof superClass&&null!==superClass)throw new TypeError('Super expression must either be null or a function, not '+typeof superClass);subClass.prototype=Object.create(superClass&&superClass.prototype,{constructor:{value:subClass,enumerable:!1,writable:!0,configurable:!0}}),superClass&&(Object.setPrototypeOf?Object.setPrototypeOf(subClass,superClass):subClass.__proto__=superClass)}function isFunction(p){return'function'==typeof p}function isPromise(){var p=0<arguments.length&&arguments[0]!==void 0?arguments[0]:{};return isFunction(p.then)}var Reactactor=exports.Reactactor=function(_Component){function Reactactor(props){_classCallCheck(this,Reactactor);var _this=_possibleConstructorReturn(this,(Reactactor.__proto__||Object.getPrototypeOf(Reactactor)).call(this,props));_this.state={};var promise=props.wait(props.passthroughProps);if(!isPromise(promise))throw new Error('you must provide an async component');return _this._promise=promise,_this}return _inherits(Reactactor,_Component),_createClass(Reactactor,[{key:'componentWillMount',value:function componentWillMount(){var _this2=this;this._promise.then(function(data){_this2.setState({data:data})}).catch(function(err){throw err})}},{key:'render',value:function render(){return this.state.data?this.state.data:null}}]),Reactactor}(_react.Component);function asyncReactor(component){if(!isFunction(component))throw new Error('you must provide an async component');return function(){var passthroughProps=0<arguments.length&&arguments[0]!==void 0?arguments[0]:{};return(0,_react.createElement)(Reactactor,{wait:component,passthroughProps:passthroughProps})}} |
{ | ||
"name": "async-reactor", | ||
"version": "1.0.2", | ||
"version": "1.0.3", | ||
"keywords": [ | ||
@@ -53,2 +53,3 @@ "react", | ||
"react-dom": "^15.5.3", | ||
"react-test-renderer": "^15.5.4", | ||
"webpack": "^2.3.3", | ||
@@ -55,0 +56,0 @@ "webpack-dev-server": "^2.4.2" |
@@ -11,3 +11,3 @@ # async-reactor | ||
## Example | ||
## Examples | ||
@@ -45,1 +45,3 @@ component.js: | ||
``` | ||
See more examples [here](https://github.com/xtuc/async-reactor-examples) |
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
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
46
95457
29
5