2 lines
12 KiB
JavaScript
2 lines
12 KiB
JavaScript
|
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("react"),require("redux")):"function"==typeof define&&define.amd?define(["exports","react","redux"],e):e(t.ReactRedux=t.ReactRedux||{},t.React,t.Redux)}(this,function(t,e,n){"use strict";function r(t){return function(){return t}}function o(){var t,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"store",r=arguments[1]||n+"Subscription",o=function(t){function o(e,r){q(this,o);var i=D(this,t.call(this,e,r));return i[n]=e.store,i}return M(o,t),o.prototype.getChildContext=function(){var t;return t={},t[n]=this[n],t[r]=null,t},o.prototype.render=function(){return e.Children.only(this.props.children)},o}(e.Component);return o.propTypes={store:j.isRequired,children:R.element.isRequired},o.childContextTypes=(t={},t[n]=j.isRequired,t[r]=x,t),o}function i(){var t=[],e=[];return{clear:function(){e=Y,t=Y},notify:function(){for(var n=t=e,r=0;n.length>r;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!==Y&&(r=!1,e===t&&(e=t.slice()),e.splice(e.indexOf(n),1))}}}}function s(){}function u(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 p(t){var n,r,o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=o.getDisplayName,p=void 0===i?function(t){return"ConnectAdvanced("+t+")"}:i,a=o.methodName,c=void 0===a?"connectAdvanced":a,d=o.renderCountProp,f=void 0===d?void 0:d,l=o.shouldHandleStateChanges,h=void 0===l||l,y=o.storeKey,b=void 0===y?"store":y,v=o.withRef,m=void 0!==v&&v,P=U(o,["getDisplayName","methodName","renderCountProp","shouldHandleStateChanges","storeKey","withRef"]),O=b+"Subscription",g=z++,S=(n={},n[b]=j,n[O]=x,n),C=(r={},r[O]=x,r);return function(n){V("function"==typeof n,"You must pass a component to the function returned by connect. Instead received "+JSON.stringify(n));var r=n.displayName||n.name||"Component",o=p(r),i=N({},P,{getDisplayName:p,methodName:c,renderCountProp:f,shouldHandleStateChanges:h,storeKey:b,withRef:m,displayName:o,wrappedComponentName:r,WrappedComponent:n}),a=function(r){function p(t,e){q(this,p);var n=D(this,r.call(this,t,e));return n.version=g,n.state={},n.renderCount=0,n.store=t[b]||e[b],n.propsMode=!!t[b],n.setWrappedInstance=n.setWrappedInstance.bind(n),V(n.store,'Could not find "'+b+'" in either the context or props of "'+o+'". Either wrap the root component in a <Provider>, or explicitly pass "'+b+'" as a prop to "'+o+'".'),n.initSelector(),n.initSubscription(),n}return M(p,r),p.prototype.getChildContext=function(){var t,e=this.propsMode?null:this.subscription;return t={},t[O]=e||this.context[O],t},p.prototype.componentDidMount=function(){h&&(this.subscription.trySubscribe(),this.selector.run(this.props),this.selector.shouldComponentUpdate&&this.forceUpdate())},p.prototype.componentWillReceiveProps=function(t){this.selector.run(t)},p.prototype.shouldComponentUpdate=function(){return this.selector.shouldComponentUpdate},p.prototype.componentWillUnmount=function(){this.subscription&&this.subscription.tryUnsubscribe(),this.subscription=null,this.notifyNestedSubs=s,this.store=null,this.selector.run=s,this.selector.shouldComponentUpdate=!1},p.prototype.getWrappedInstance=function(){return V(m,"To access the wrapped instance, you need to specify { withRef: true } in the options argument of the "+c+"() call."),this.wrappedInstance},p.prototype.setWrappedInstance=function(t){this.wrappedInstance=t},p.prototype.initSelector=function(){var e=t(this.store.dispatch,i);(this.selector=u(e,this.store)).run(this.props)},p.prototype.initSubscription=function(){if(h){var t=(this.propsMode?this.props:this.context)[O];this.subscription=new J(this.store,t,this.onStateChange.bind(this)),this.notifyNestedSubs=this.subscription.notifyNestedSubs.bind(this.subscription)}},p.prototype.onStateChange=function(){this.selector.run(this.props),this.selector.shouldComponentUpdate?(this.componentDidUpdate=this.
|