effector-react
Advanced tools
Comparing version 0.18.0-rc.2 to 0.18.0-rc.3
@@ -1,2 +0,2 @@ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("react"),e=require("effector");function r(e){var r,n;return n=r=class extends t.Component{constructor(...t){super(...t),this.state={currentState:e.getState()},this._unsubscribe=null,this._hasUnmounted=!1}componentDidMount(){this.subscribe()}componentWillUnmount(){this.unsubscribe(),this._hasUnmounted=!0}render(){return this.props.children(this.state.currentState)}subscribe(){const t=e.subscribe(t=>{this._hasUnmounted||this.setState(e=>t===e.currentState?null:{currentState:t})});this._unsubscribe=t}unsubscribe(){"function"==typeof this._unsubscribe&&this._unsubscribe(),this._unsubscribe=null}},r.displayName=`${e.shortName}.Consumer`,n}function n(e){var r,n;return n=r=class extends t.Component{constructor(...t){super(...t),this.state={currentValue:null}}static getDerivedStateFromProps(t){return e.setState(t.value),{currentValue:t.value}}render(){return this.props.children}},r.displayName=`${e.shortName}.Provider`,r.defaultProps={children:null},n}function s(e,n,s){var o,c;const u=r(e);return c=o=class extends t.Component{constructor(...t){super(...t),this.renderProp=(t=>s(this.props,t,this.context))}render(){return t.createElement(u,null,this.renderProp)}},o.contextType=n,c}function o(e,n){const s=r(e);return class extends t.Component{constructor(...t){super(...t),this.renderProp=(t=>n(this.props,t))}render(){return t.createElement(s,null,this.renderProp)}}}function c(){return(c=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t}).apply(this,arguments)}function u(e,n){const s=r(e),o=e=>t.createElement(s,null,r=>t.createElement(n,c({},e,r)));return o.displayName=`Connect(${n.displayName||n.name||"Unknown"})`,o}function a(t){return e=>u(e,t)}const{store:i}=e.createDomain("Gate");function p(r="gate",n={}){const s=i(!1),o=i(n),{set:c}=e.createApi(o,{set:(t,e)=>e}),{open:u,close:a,destructor:l}=e.createApi(s,{open:()=>d.predicate()&&!0,close:()=>!1,destructor:()=>!1});class d extends t.PureComponent{static childGate(t="Subgate"){const e=p(`${r}/${t}`);e.predicate=(()=>d.status.getState());let n=!1,s=!1;return e.open.watch(()=>{s||(n=!0)}),e.close.watch(()=>{s||(n=!1)}),d.status.watch(t=>{s=!0,n&&t&&!e.status.getState()&&e.open(),s=!1}),d.close.watch(()=>{s=!0,e.close(),s=!1}),d.destructor.watch(()=>e.destructor()),e}componentDidMount(){d.open()}componentWillUnmount(){d.close()}render(){return d.set(this.props),null}}d.predicate=(()=>!0),d.displayName=`Gate:${r}`,d.isOpen=!1,d.current=o.getState(),d.open=u,d.close=a,d.status=s,d.state=o,d.set=c,d.destructor=l,d.isTerminated=!1;const h=s.watch(t=>d.isOpen=t),m=o.watch(t=>d.current=t);s.map(t=>{t||(d.current=n)});o.reset(a);const b=l.watch(()=>{d.isTerminated=!0}),f=l.watch(()=>{f(),h(),m(),b(),d.status.off(d.open),d.status.off(d.close),d.status.off(d.destructor),d.state.off(d.set)});return d}exports.createStoreConsumer=r,exports.unstable_createStoreProvider=n,exports.createContextComponent=s,exports.createComponent=o,exports.connect=a,exports.createReactState=u,exports.createGate=p; | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("react"),effector=require("effector");function e(e){var r,n;return n=r=class extends t.Component{constructor(...t){super(...t),this.state={currentState:e.getState()},this._unsubscribe=null,this._hasUnmounted=!1}componentDidMount(){this.subscribe()}componentWillUnmount(){this.unsubscribe(),this._hasUnmounted=!0}render(){return this.props.children(this.state.currentState)}subscribe(){const t=e.subscribe(t=>{this._hasUnmounted||this.setState(e=>t===e.currentState?null:{currentState:t})});this._unsubscribe=t}unsubscribe(){"function"==typeof this._unsubscribe&&this._unsubscribe(),this._unsubscribe=null}},r.displayName=`${e.shortName}.Consumer`,n}function r(e){var r,n;return n=r=class extends t.Component{constructor(...t){super(...t),this.state={currentValue:null}}static getDerivedStateFromProps(t){return e.setState(t.value),{currentValue:t.value}}render(){return this.props.children}},r.displayName=`${e.shortName}.Provider`,r.defaultProps={children:null},n}function n(r,n,s){var o,c;const u=e(r);return c=o=class extends t.Component{constructor(...t){super(...t),this.renderProp=(t=>s(this.props,t,this.context))}render(){return t.createElement(u,null,this.renderProp)}},o.contextType=n,c}function s(r,n){const s=e(r);return class extends t.Component{constructor(...t){super(...t),this.renderProp=(t=>n(this.props,t))}render(){return t.createElement(s,null,this.renderProp)}}}function o(){return(o=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t}).apply(this,arguments)}function c(r,n){const s=e(r),c=e=>t.createElement(s,null,r=>t.createElement(n,o({},e,r)));return c.displayName=`Connect(${n.displayName||n.name||"Unknown"})`,c}function u(t){return e=>c(e,t)}const{store:a}=effector.createDomain("Gate");function i(e="gate",r={}){const n=a(!1),s=a(r),{set:o}=effector.createApi(s,{set:(t,e)=>e}),{open:c,close:u,destructor:p}=effector.createApi(n,{open:()=>l.predicate()&&!0,close:()=>!1,destructor:()=>!1});class l extends t.PureComponent{static childGate(t="Subgate"){const r=i(`${e}/${t}`);r.predicate=(()=>l.status.getState());let n=!1,s=!1;return r.open.watch(()=>{s||(n=!0)}),r.close.watch(()=>{s||(n=!1)}),l.status.watch(t=>{s=!0,n&&t&&!r.status.getState()&&r.open(),s=!1}),l.close.watch(()=>{s=!0,r.close(),s=!1}),l.destructor.watch(()=>r.destructor()),r}componentDidMount(){l.open()}componentWillUnmount(){l.close()}render(){return l.set(this.props),null}}l.predicate=(()=>!0),l.displayName=`Gate:${e}`,l.isOpen=!1,l.current=s.getState(),l.open=c,l.close=u,l.status=n,l.state=s,l.set=o,l.destructor=p,l.isTerminated=!1;const d=n.watch(t=>l.isOpen=t),h=s.watch(t=>l.current=t);n.map(t=>{t||(l.current=r)});s.reset(u);const m=p.watch(()=>{l.isTerminated=!0}),b=p.watch(()=>{b(),d(),h(),m(),l.status.off(l.open),l.status.off(l.close),l.status.off(l.destructor),l.state.off(l.set)});return l}exports.createStoreConsumer=e,exports.unstable_createStoreProvider=r,exports.createContextComponent=n,exports.createComponent=s,exports.connect=u,exports.createReactState=c,exports.createGate=i; | ||
//# sourceMappingURL=effector-react.cjs.js.map |
{ | ||
"name": "effector-react", | ||
"version": "0.18.0-rc.2", | ||
"version": "0.18.0-rc.3", | ||
"description": "React bindings for effector", | ||
@@ -5,0 +5,0 @@ "main": "effector-react.cjs.js", |
Sorry, the diff of this file is not supported yet
39292