effector-react
Advanced tools
Comparing version 0.18.0-beta.11 to 0.18.0-rc.1
@@ -1,2 +0,2 @@ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("react"),e=require("effector");function r(e){var r,s;return s=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`,s}function s(e){var r,s;return s=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},s}function n(e,s){const n=r(e);return class extends t.Component{constructor(...t){super(...t),this.renderProp=(t=>s(this.props,t))}render(){return t.createElement(n,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 s in r)Object.prototype.hasOwnProperty.call(r,s)&&(t[s]=r[s])}return t}).apply(this,arguments)}function c(e,s){const n=r(e),c=e=>t.createElement(n,null,r=>t.createElement(s,o({},e,r)));return c.displayName=`Connect(${s.displayName||s.name||"Unknown"})`,c}function a(t){return e=>c(e,t)}const{store:u}=e.createDomain("Gate");function i(r="gate"){const s=u(!1),n={},o=u(n),{set:c}=e.createApi(o,{set:(t,e)=>e}),{open:a,close:p,destructor:l}=e.createApi(s,{open:()=>d.predicate()&&!0,close:()=>!1,destructor:()=>!1});class d extends t.PureComponent{static childGate(t="Subgate"){const e=i(`${r}/${t}`);e.predicate=(()=>d.status.getState());let s=!1,n=!1;return e.open.watch(()=>{n||(s=!0)}),e.close.watch(()=>{n||(s=!1)}),d.status.watch(t=>{n=!0,s&&t&&!e.status.getState()&&e.open(),n=!1}),d.close.watch(()=>{n=!0,e.close(),n=!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=a,d.close=p,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(p);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=s,exports.createComponent=n,exports.connect=a,exports.createReactState=c,exports.createGate=i; | ||
"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"){const n=i(!1),s={},o=i(s),{set:c}=e.createApi(o,{set:(t,e)=>e}),{open:u,close:a,destructor:l}=e.createApi(n,{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=n,d.state=o,d.set=c,d.destructor=l,d.isTerminated=!1;const h=n.watch(t=>d.isOpen=t),m=o.watch(t=>d.current=t);n.map(t=>{t||(d.current=s)});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; | ||
//# sourceMappingURL=effector-react.cjs.js.map |
@@ -1,2 +0,2 @@ | ||
import{Component as t,createElement as e,PureComponent as s}from"react";import{createDomain as r,createApi as n}from"effector";function o(e){var s,r;return r=s=class extends t{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}},s.displayName=`${e.shortName}.Consumer`,r}function u(e){var s,r;return r=s=class extends t{constructor(...t){super(...t),this.state={currentValue:null}}static getDerivedStateFromProps(t){return e.setState(t.value),{currentValue:t.value}}render(){return this.props.children}},s.displayName=`${e.shortName}.Provider`,s.defaultProps={children:null},r}function c(s,r){const n=o(s);return class extends t{constructor(...t){super(...t),this.renderProp=(t=>r(this.props,t))}render(){return e(n,null,this.renderProp)}}}function a(){return(a=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var s=arguments[e];for(var r in s)Object.prototype.hasOwnProperty.call(s,r)&&(t[r]=s[r])}return t}).apply(this,arguments)}function i(t,s){const r=o(t),n=t=>e(r,null,r=>e(s,a({},t,r)));return n.displayName=`Connect(${s.displayName||s.name||"Unknown"})`,n}function l(t){return e=>i(e,t)}const{store:p}=r("Gate");function h(t="gate"){const e=p(!1),r={},o=p(r),{set:u}=n(o,{set:(t,e)=>e}),{open:c,close:a,destructor:i}=n(e,{open:()=>l.predicate()&&!0,close:()=>!1,destructor:()=>!1});class l extends s{static childGate(e="Subgate"){const s=h(`${t}/${e}`);s.predicate=(()=>l.status.getState());let r=!1,n=!1;return s.open.watch(()=>{n||(r=!0)}),s.close.watch(()=>{n||(r=!1)}),l.status.watch(t=>{n=!0,r&&t&&!s.status.getState()&&s.open(),n=!1}),l.close.watch(()=>{n=!0,s.close(),n=!1}),l.destructor.watch(()=>s.destructor()),s}componentDidMount(){l.open()}componentWillUnmount(){l.close()}render(){return l.set(this.props),null}}l.predicate=(()=>!0),l.displayName=`Gate:${t}`,l.isOpen=!1,l.current=o.getState(),l.open=c,l.close=a,l.status=e,l.state=o,l.set=u,l.destructor=i,l.isTerminated=!1;const d=e.watch(t=>l.isOpen=t),m=o.watch(t=>l.current=t);e.map(t=>{t||(l.current=r)});o.reset(a);const f=i.watch(()=>{l.isTerminated=!0}),b=i.watch(()=>{b(),d(),m(),f(),l.status.off(l.open),l.status.off(l.close),l.status.off(l.destructor),l.state.off(l.set)});return l}export{o as createStoreConsumer,u as unstable_createStoreProvider,c as createComponent,l as connect,i as createReactState,h as createGate}; | ||
import{Component as t,createElement as e,PureComponent as r}from"react";import{createDomain as s,createApi as n}from"effector";function o(e){var r,s;return s=r=class extends t{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`,s}function u(e){var r,s;return s=r=class extends t{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},s}function c(r,s,n){var u,c;const a=o(r);return c=u=class extends t{constructor(...t){super(...t),this.renderProp=(t=>n(this.props,t,this.context))}render(){return e(a,null,this.renderProp)}},u.contextType=s,c}function a(r,s){const n=o(r);return class extends t{constructor(...t){super(...t),this.renderProp=(t=>s(this.props,t))}render(){return e(n,null,this.renderProp)}}}function i(){return(i=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(t[s]=r[s])}return t}).apply(this,arguments)}function l(t,r){const s=o(t),n=t=>e(s,null,s=>e(r,i({},t,s)));return n.displayName=`Connect(${r.displayName||r.name||"Unknown"})`,n}function p(t){return e=>l(e,t)}const{store:h}=s("Gate");function d(t="gate"){const e=h(!1),s={},o=h(s),{set:u}=n(o,{set:(t,e)=>e}),{open:c,close:a,destructor:i}=n(e,{open:()=>l.predicate()&&!0,close:()=>!1,destructor:()=>!1});class l extends r{static childGate(e="Subgate"){const r=d(`${t}/${e}`);r.predicate=(()=>l.status.getState());let s=!1,n=!1;return r.open.watch(()=>{n||(s=!0)}),r.close.watch(()=>{n||(s=!1)}),l.status.watch(t=>{n=!0,s&&t&&!r.status.getState()&&r.open(),n=!1}),l.close.watch(()=>{n=!0,r.close(),n=!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:${t}`,l.isOpen=!1,l.current=o.getState(),l.open=c,l.close=a,l.status=e,l.state=o,l.set=u,l.destructor=i,l.isTerminated=!1;const p=e.watch(t=>l.isOpen=t),f=o.watch(t=>l.current=t);e.map(t=>{t||(l.current=s)});o.reset(a);const m=i.watch(()=>{l.isTerminated=!0}),b=i.watch(()=>{b(),p(),f(),m(),l.status.off(l.open),l.status.off(l.close),l.status.off(l.destructor),l.state.off(l.set)});return l}export{o as createStoreConsumer,u as unstable_createStoreProvider,c as createContextComponent,a as createComponent,p as connect,l as createReactState,d as createGate}; | ||
//# sourceMappingURL=effector-react.es.js.map |
@@ -18,4 +18,9 @@ | ||
): React.ComponentType<Props> | ||
export function createContextComponent<Props, State, Context>( | ||
store: Store<State>, | ||
context: React.Context<Context>, | ||
renderProp: (props: Props, state: State, context: Context) => React.ReactNode, | ||
): React.ComponentType<Props> | ||
export type Gate<Props = {}> = React.ComponentType<Props>> & { | ||
export type Gate<Props = {}> = React.ComponentType<Props> & { | ||
isOpen: boolean, | ||
@@ -22,0 +27,0 @@ isTerminated: boolean, |
@@ -13,3 +13,3 @@ { | ||
"dependencies": { | ||
"effector": "^0.18.0-beta.11" | ||
"effector": "^0.18.0-rc.1" | ||
}, | ||
@@ -61,3 +61,3 @@ "peerDependencies": { | ||
], | ||
"version": "0.18.0-beta.11" | ||
"version": "0.18.0-rc.1" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
39133
75
Updatedeffector@^0.18.0-rc.1