rxact-react
Version:
React bindings for Rxact
1 lines • 5.84 kB
JavaScript
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("rxact"),require("react")):"function"==typeof define&&define.amd?define(["rxact","react"],e):"object"==typeof exports?exports["rxcat-react"]=e(require("rxact"),require("react")):t["rxcat-react"]=e(t.Rxact,t.React)}(this,function(t,e){return function(t){function e(r){if(n[r])return n[r].exports;var o=n[r]={i:r,l:!1,exports:{}};return t[r].call(o.exports,o,o.exports,e),o.l=!0,o.exports}var n={};return e.m=t,e.c=n,e.d=function(t,n,r){e.o(t,n)||Object.defineProperty(t,n,{configurable:!1,enumerable:!0,get:r})},e.n=function(t){var n=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(n,"a",n),n},e.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},e.p="",e(e.s=2)}([function(t,e,n){"use strict";function r(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function o(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}function u(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}Object.defineProperty(e,"__esModule",{value:!0}),e.decorator=e.plugin=void 0;var i=(n(1),n(3)),c=function(t){return t&&t.__esModule?t:{default:t}}(i),s=e.plugin=function(){return function(t){t.observer=(0,c.default)(t.state$).decorator}};e.decorator=function(){return function(t){return function(t){function e(){var t,n,u;r(this,e);for(var i=arguments.length,c=Array(i),a=0;i>a;a++)c[a]=arguments[a];var f=n=o(this,(t=e.__proto__||Object.getPrototypeOf(e)).call.apply(t,[this].concat(c)));return u=s()(f),o(n,u)}return u(e,t),e}(t)}}},function(e,n){e.exports=t},function(t,e,n){n(0),t.exports=n(0)},function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{default:t}}function o(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function u(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}function i(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}Object.defineProperty(e,"__esModule",{value:!0});var c=function(){function t(t,e){for(var n=0;e.length>n;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}return function(e,n,r){return n&&t(e.prototype,n),r&&t(e,r),e}}(),s=Object.assign||function(t){for(var e=1;arguments.length>e;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},a=n(4),f=r(a),p=n(5),l=r(p),b=n(1),y=n(6),d=r(y),v=n(7),h=r(v),O=function(t){return"RxactObserver("+(t.displayName||t.name||"Component")+")"},m=function(t,e){return s({},e,t)};e.default=function(t){var e=(0,b.getObservable)();if(!(0,b.isObservable)(t))throw Error("Expect state$ to be instance of Observable");return{decorator:function(n){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:m;return function(s){var a=function(a){function f(i){o(this,f);var c=u(this,(f.__proto__||Object.getPrototypeOf(f)).call(this,i));return c.subscription=null,c.streamSubscription=null,c.propSubscription=null,c.setProps=d.default,c.props$=d.default,c.state={component:null},c.component=null,c.initialSubscriptions=function(){var o=t,u=new e(function(t){var e=0,u=void 0,i=void 0,a=function(){if(2>e&&(e+=1),e>1){var o=u;"function"==typeof n&&(o=n(u,i));var c=r(o,i),a=l.default.createElement(s,c);t.next(a)}};return c.propSubscription=c.props$.subscribe(function(t){i=t,a()}),c.streamSubscription=o.subscribe(function(t){u=t,a()}),{unsubscribe:function(){}}});c.subscription=u.subscribe(function(t){c.component=t,c.subscription&&c.forceUpdate()})},c.props$=new e(function(t){return c.setProps=function(e){return t.next(e)},c.setProps(c.props),{unsubscribe:function(){c.setProps=d.default}}}),c.initialSubscriptions(),c}return i(f,a),c(f,[{key:"componentWillUnmount",value:function(){this.subscription&&(this.subscription=null);var t=this.streamSubscription;t&&(0,h.default)(t.unsubscribe)&&t.unsubscribe();var e=this.propSubscription;e&&(0,h.default)(e.unsubscribe)&&e.unsubscribe()}},{key:"componentWillReceiveProps",value:function(t){this.setProps(t)}},{key:"shouldComponentUpdate",value:function(){return!1}},{key:"render",value:function(){return this.component}}]),f}(p.Component);return a.displayName=O(s),(0,f.default)(a,s)}}}}},function(t,e,n){"use strict";var r={childContextTypes:!0,contextTypes:!0,defaultProps:!0,displayName:!0,getDefaultProps:!0,mixins:!0,propTypes:!0,type:!0},o={name:!0,length:!0,prototype:!0,caller:!0,callee:!0,arguments:!0,arity:!0},u=Object.defineProperty,i=Object.getOwnPropertyNames,c=Object.getOwnPropertySymbols,s=Object.getOwnPropertyDescriptor,a=Object.getPrototypeOf,f=a&&a(Object);t.exports=function t(e,n,p){if("string"!=typeof n){if(f){var l=a(n);l&&l!==f&&t(e,l,p)}var b=i(n);c&&(b=b.concat(c(n)));for(var y=0;b.length>y;++y){var d=b[y];if(!(r[d]||o[d]||p&&p[d])){var v=s(n,d);try{u(e,d,v)}catch(t){}}}return e}return e}},function(t,n){t.exports=e},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.default=function(){}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.default=function(t){return"function"==typeof t}}])});