You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

2 lines
12 KiB

7 years ago
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e(require("preact"),require("redux")):"function"==typeof define&&define.amd?define(["preact","redux"],e):t.preactRedux=e(t.preact,t.Redux)}(this,function(t,e){function n(){}function r(){z||(z=!0)}function o(){var t=[],e=[];return{clear:function(){e=et,t=et},notify:function(){for(var n=t=e,r=0;r<n.length;r++)n[r]()},get:function(){return e},subscribe:function(n){var r=!0;return e===t&&(e=t.slice()),e.push(n),function(){r&&t!==et&&(r=!1,e===t&&(e=t.slice()),e.splice(e.indexOf(n),1))}}}}function i(){}function s(t,e){var n={run:function(r){try{var o=t(e.getState(),r);(o!==n.props||n.error)&&(n.shouldComponentUpdate=!0,n.props=o,n.error=null)}catch(t){n.shouldComponentUpdate=!0,n.error=t}}};return n}function u(e){var n,r,o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},u=o.getDisplayName,p=void 0===u?function(t){return"ConnectAdvanced("+t+")"}:u,c=o.methodName,a=void 0===c?"connectAdvanced":c,d=o.renderCountProp,f=void 0===d?void 0:d,l=o.shouldHandleStateChanges,h=void 0===l||l,b=o.storeKey,y=void 0===b?"store":b,v=o.withRef,m=void 0!==v&&v,P=k(o,["getDisplayName","methodName","renderCountProp","shouldHandleStateChanges","storeKey","withRef"]),O=y+"Subscription",S=ot++,g=(n={},n[y]=H,n[O]=F,n),w=(r={},r[O]=F,r);return function(n){JSON.stringify(n);var r=n.displayName||n.name||"Component",o=p(r),u=_({},P,{getDisplayName:p,methodName:a,renderCountProp:f,shouldHandleStateChanges:h,storeKey:y,withRef:m,displayName:o,wrappedComponentName:r,WrappedComponent:n}),c=function(r){function o(t,e){var n=J(this,r.call(this,t,e));return n.version=S,n.state={},n.renderCount=0,n.store=t[y]||e[y],n.propsMode=!!t[y],n.setWrappedInstance=n.setWrappedInstance.bind(n),n.initSelector(),n.initSubscription(),n}return K(o,r),o.prototype.getChildContext=function(){var t,e=this.propsMode?null:this.subscription;return t={},t[O]=e||this.context[O],t},o.prototype.componentDidMount=function(){h&&(this.subscription.trySubscribe(),this.selector.run(this.props),this.selector.shouldComponentUpdate&&this.forceUpdate())},o.prototype.componentWillReceiveProps=function(t){this.selector.run(t)},o.prototype.shouldComponentUpdate=function(){return this.selector.shouldComponentUpdate},o.prototype.componentWillUnmount=function(){this.subscription&&this.subscription.tryUnsubscribe(),this.subscription=null,this.notifyNestedSubs=i,this.store=null,this.selector.run=i,this.selector.shouldComponentUpdate=!1},o.prototype.getWrappedInstance=function(){return this.wrappedInstance},o.prototype.setWrappedInstance=function(t){this.wrappedInstance=t},o.prototype.initSelector=function(){this.selector=s(e(this.store.dispatch,u),this.store),this.selector.run(this.props)},o.prototype.initSubscription=function(){if(h){this.subscription=new rt(this.store,(this.propsMode?this.props:this.context)[O],this.onStateChange.bind(this)),this.notifyNestedSubs=this.subscription.notifyNestedSubs.bind(this.subscription)}},o.prototype.onStateChange=function(){this.selector.run(this.props),this.selector.shouldComponentUpdate?(this.componentDidUpdate=this.notifyNestedSubsOnComponentDidUpdate,this.setState(it)):this.notifyNestedSubs()},o.prototype.notifyNestedSubsOnComponentDidUpdate=function(){this.componentDidUpdate=void 0,this.notifyNestedSubs()},o.prototype.isSubscribed=function(){return!!this.subscription&&this.subscription.isSubscribed()},o.prototype.addExtraProps=function(t){if(!(m||f||this.propsMode&&this.subscription))return t;var e=_({},t);return m&&(e.ref=this.setWrappedInstance),f&&(e[f]=this.renderCount++),this.propsMode&&this.subscription&&(e[O]=this.subscription),e},o.prototype.render=function(){var e=this.selector;if(e.shouldComponentUpdate=!1,e.error)throw e.error;return t.h(n,this.addExtraProps(e.props))},o}(t.Component);return c.WrappedComponent=n,c.displayName=o,c.childContextTypes=w,c.contextTypes=g,c.prototype.componentWillUpdate=function(){var t=this;if(this.version!==S){this.version=S,this.initSelector();var e=[];this.subscription&&(e=this.subscription.listeners.get(),this.subscription.tr
//# sourceMappingURL=preact-redux.min.js.map