Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

async-reactor

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

async-reactor - npm Package Compare versions

Comparing version 1.0.5 to 1.1.0

lib/element.js

2

lib/index.js

@@ -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.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)}function defer(fn){setTimeout(fn,0)}var Reactor=function(_Component){function Reactor(props){_classCallCheck(this,Reactor);var _this=_possibleConstructorReturn(this,(Reactor.__proto__||Object.getPrototypeOf(Reactor)).call(this,props));return _this.state={},_this}return _inherits(Reactor,_Component),_createClass(Reactor,[{key:'componentWillMount',value:function componentWillMount(){var _this2=this;defer(function(){var promise=_this2.props.wait(_this2.props.passthroughProps);if(!isPromise(promise))throw new Error('You must provide an async component');promise.then(function(data){_this2.setState({data:data})}).catch(function(err){throw err})})}},{key:'render',value:function render(){return'data'in this.state?this.state.data:(0,_react.createElement)(this.props.loader)}}]),Reactor}(_react.Component);function asyncReactor(component){var loaderComponent=1<arguments.length&&arguments[1]!==void 0?arguments[1]:'div';if(!isFunction(component))throw new Error('You must provide an async component, '+JSON.stringify(component)+' given');return function(){var passthroughProps=0<arguments.length&&arguments[0]!==void 0?arguments[0]:{};return(0,_react.createElement)(Reactor,{wait:component,loader:loaderComponent,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.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 Reactor=function(_Component){function Reactor(props){_classCallCheck(this,Reactor);var _this=_possibleConstructorReturn(this,(Reactor.__proto__||Object.getPrototypeOf(Reactor)).call(this,props));return _this.state={},_this}return _inherits(Reactor,_Component),_createClass(Reactor,[{key:'componentDidMount',value:function componentDidMount(){var _this2=this,promise=this.props.wait(this.props.passthroughProps);if(!isPromise(promise))throw new Error('You must provide an async component');promise.then(function(data){_this2.setState({data:data})}).catch(function(err){throw err})}},{key:'render',value:function render(){return'data'in this.state?this.state.data:(0,_react.createElement)(this.props.loader)}}]),Reactor}(_react.Component);function asyncReactor(component){var loaderComponent=1<arguments.length&&arguments[1]!==void 0?arguments[1]:'div';if((0,_react.isValidElement)(component))throw new Error('Incompatible React element given, please change asyncReactor(<'+component.type.name+' />) to asyncReactor('+component.type.name+').');if(!isFunction(component))throw new Error('You must provide an async component, '+JSON.stringify(component)+' given');return function(){var passthroughProps=0<arguments.length&&arguments[0]!==void 0?arguments[0]:{};return(0,_react.createElement)(Reactor,{wait:component,loader:loaderComponent,passthroughProps:passthroughProps})}}
{
"name": "async-reactor",
"version": "1.0.5",
"version": "1.1.0",
"keywords": [

@@ -5,0 +5,0 @@ "react",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc