fastflux
Version:
Message driven reactive state management
2 lines • 8.57 kB
JavaScript
!function(t){function e(n){if(r[n])return r[n].exports;var o=r[n]={exports:{},id:n,loaded:!1};return t[n].call(o.exports,o,o.exports,e),o.loaded=!0,o.exports}var r={};return e.m=t,e.c=r,e.p="",e(0)}([function(t,e,r){"use strict";!function(t){t.Fastflux=t.Fastflux||r(9)}(window)},function(t,e,r){"use strict";function n(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")}e.__esModule=!0;var s=r(2),i=n(s),u=r(3),c=n(u),a=function(){function t(){o(this,t),this._listeners=[]}return t.prototype.subscribe=function(t){if(-1===this._listeners.indexOf(t))return this._listeners.push(t),new c["default"](this,t);throw new Error("subscribe: cannot register twice")},t.prototype.hasSubscribed=function(t){return-1!==this._listeners.indexOf(t)},t.prototype.unsubscribe=function(t){var e=this._listeners.indexOf(t);if(-1===e)throw new Error("unsubscribe: listener is not registered");this._listeners.splice(e,1)},t.prototype.emit=function(t){for(var e=this._listeners.length,r=0;e>r;r++)this._listeners[r](t)},t.prototype.map=function(e){var r=new t;return this.subscribe(function(t){r.emit(e(t))}),r},t.prototype.filter=function(e){var r=new t;return this.subscribe(function(t){e(t)&&r.emit(t)}),r},t.prototype.reduce=function(t,e){var r=new i["default"](t);return this.subscribe(function(t){r.getState(function(n){r.emit(e(n,t))})}),r},t}();e["default"]=a,t.exports=e["default"]},function(t,e,r){"use strict";function n(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 s(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)}e.__esModule=!0;var i=r(1),u=n(i),c=function(t){function e(r){o(this,e),t.call(this),this._state=null!=r?r:null}return s(e,t),e.prototype.getState=function(t){var e=this._state;return"function"==typeof t?void setTimeout(function(){return t(e)}):e},e.prototype.emit=function(e){this._state=null!=e?e:null,t.prototype.emit.call(this,this._state)},e.prototype.map=function(e){return t.prototype.reduce.call(this,e(this.getState()),function(t,r){return e(r)})},e.prototype.filter=function(e){var r=this.getState();return e(r)||(r=null),t.prototype.filter.call(this,e).reduce(r,function(t,e){return e})},e.prototype.reduce=function(e,r){return t.prototype.reduce.call(this,r(e,this.getState()),r)},e}(u["default"]);e["default"]=c,t.exports=e["default"]},function(t,e,r){"use strict";function n(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")}e.__esModule=!0;var s=r(1),i=(n(s),function(){function t(e,r){o(this,t),this._source=e,this._subscriber=r}return t.prototype.isActive=function(){return this._source.hasSubscribed(this._subscriber)},t.prototype.activate=function(){this._source.subscribe(this._subscriber)},t.prototype.terminate=function(){this._source.unsubscribe(this._subscriber)},t}());e["default"]=i,t.exports=e["default"]},function(t,e,r){"use strict";function n(t){return t&&t.__esModule?t:{"default":t}}function o(t){return c["default"]({},t)}function s(t){return null!=t&&"function"==typeof t.subscribe&&"function"==typeof t.unsubscribe}function i(t){return s(t)&&"function"==typeof t.getState}e.__esModule=!0,e.clone=o,e.isObservable=s,e.isObservableState=i;var u=r(10),c=n(u);e.assign=c["default"]},function(t,e,r){"use strict";function n(t){return t&&t.__esModule?t:{"default":t}}function o(t){var e=t(function(t){return r.emit(t)}),r=function(){e.apply(void 0,arguments)};return r=u.assign(r,i["default"].prototype),r._listeners=[],r}e.__esModule=!0,e.createAction=o;var s=r(1),i=n(s),u=r(4)},function(t,e,r){"use strict";function n(t){return t&&t.__esModule?t:{"default":t}}e.__esModule=!0;var o=r(1),s=n(o),i=r(2),u=n(i),c=r(3),a=n(c);e.Observable=s["default"],e.ObservableState=u["default"],e.Subscription=a["default"]},function(t,e,r){"use strict";function n(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 s(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)}function i(){var t=arguments.length<=0||void 0===arguments[0]?{}:arguments[0],e=t.getInitialState,r=t.reducer,n=t.reducers;null==n&&(n=r);var i=function(t){function e(){o(this,e),t.apply(this,arguments)}return s(e,t),e}(a);return null!=e&&(i.prototype.getInitialState=e),null!=n&&(i.reducers=n),new i}e.__esModule=!0,e.createStore=i;var u=r(2),c=n(u),a=function(t){function e(){var r=this;if(o(this,e),t.call(this),this.constructor===e)throw new Error("Store is abstract: extend or call createStore");var n=this.constructor.reducers||this.constructor.reducer,s=this.getInitialState();if("object"!=typeof n&&"function"!=typeof n)throw new Error("Expecting reducer function or object mapping message types -> reducer functions in static property reducers");this._reducers=n,this._state=s,this._isProcessing=!1;var i=this.send;this.send=function(t,e){return i.call(r,t,e)}}return s(e,t),e.prototype.getInitialState=function(){throw new Error("Not implemented")},e.prototype.send=function(t,e){for(;;)if(!this._isProcessing)break;this._process(t,e)},e.prototype._process=function(e,r){this._isProcessing=!0;var n=void 0;if("object"==typeof this._reducers){if(!this._reducers.hasOwnProperty(e.type))return void(this._isProcessing=!1);n=this._reducers[e.type]}else n=this._reducers;var o=this.getState(),s=n(o,e,null!=r?r:null);return null!=s&&"function"==typeof s.equals&&s.equals(o)?void(this._isProcessing=!1):(void 0!==s&&t.prototype.emit.call(this,s),void(this._isProcessing=!1))},e.prototype.emit=function(){throw new Error("Disabled")},e}(c["default"]);e.Store=a},function(t,e,r){"use strict";function n(t){return t&&t.__esModule?t:{"default":t}}function o(t){var e=function(t,e){i.Component.call(this,t,e),this.normalProps={},this.observableProps={},this.updaters={};var r={};for(var n in this.props){var o=this.props[n];s.isObservableState(o)?(this.observableProps[n]=o,r[n]=o.getState()):this.normalProps[n]=o}this.state=r};return e.prototype=Object.create(i.Component.prototype,{constructor:{value:e},componentWillMount:{value:function(){var t=this,e=function(e){var r=t.observableProps[e],n=t.updaters[e]=function(r){var n={};n[e]=r,t.setState(n)};r.subscribe(n)};for(var r in this.observableProps)e(r)}},componentWillUnmount:{value:function(){for(var t in this.updaters)this.observableProps[t].unsubscribe(this.updaters[t]),delete this.updaters[t]}},componentWillReceiveProps:{value:function(t){for(var e in this.observableProps)if(t[e]!==this.observableProps[e])throw new Error("Cannot change an observable state prop once initialized. To change the value, call setState");for(var e in this.normalProps)void 0===t[e]&&delete this.normalProps[e];for(var e in t){var r=t[e];if(!(e in this.observableProps)){if(s.isObservableState(r))throw new Error("Cannot change non-observable prop to observable once initialized");this.normalProps[e]=r}}}},render:{value:function(){return i.createElement(t,s.assign({},this.normalProps,this.state))}}}),e}e.__esModule=!0,e.createSubscriber=o;var s=r(4),i=r(11),u=r(2);n(u)},function(t,e,r){"use strict";e.__esModule=!0;var n=r(7);e.Store=n.Store,e.createStore=n.createStore;var o=r(6);e.Observable=o.Observable,e.ObservableState=o.ObservableState,e.Subscription=o.Subscription;var s=r(8);e.createSubscriber=s.createSubscriber;var i=r(5);e.createAction=i.createAction},function(t,e){"use strict";function r(t){if(null===t||void 0===t)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(t)}var n=Object.prototype.hasOwnProperty,o=Object.prototype.propertyIsEnumerable;t.exports=Object.assign||function(t,e){for(var s,i,u=r(t),c=1;c<arguments.length;c++){s=Object(arguments[c]);for(var a in s)n.call(s,a)&&(u[a]=s[a]);if(Object.getOwnPropertySymbols){i=Object.getOwnPropertySymbols(s);for(var l=0;l<i.length;l++)o.call(s,i[l])&&(u[i[l]]=s[i[l]])}}return u}},function(t,e){t.exports=React}]);
//# sourceMappingURL=fastflux.min.js.map