Comparing version 1.5.1 to 1.5.2
@@ -1,2 +0,2 @@ | ||
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("immutable")):"function"==typeof define&&define.amd?define(["immutable"],e):"object"==typeof exports?exports.immview=e(require("immutable")):t.immview=e(t.immutable)}(this,function(t){return function(t){function e(r){if(n[r])return n[r].exports;var o=n[r]={exports:{},id:r,loaded:!1};return t[r].call(o.exports,o,o.exports,e),o.loaded=!0,o.exports}var n={};return e.m=t,e.c=n,e.p="",e(0)}([function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}Object.defineProperty(e,"__esModule",{value:!0}),e.dispatch=e.Dispatcher=e.Throttle=e.Debounce=e.Domain=e.View=e.Data=void 0;var o=n(1),i=r(o),u=n(3),s=r(u),c=n(8),a=r(c),f=n(9),l=r(f),d=n(10),h=r(d),p=n(2),m=r(p),v=m.default.dispatch;e.Data=s.default,e.View=a.default,e.Domain=i.default,e.Debounce=l.default,e.Throttle=h.default,e.Dispatcher=m.default,e.dispatch=v},function(t,e,n){"use strict";function r(t,e){if(!t.subscribe)throw Error(u+" stream source required");this.stream=t,this._claimActions(e)}Object.defineProperty(e,"__esModule",{value:!0}),e.default=r;var o=n(2),i=function(){return null},u="Immview::Domain: ";r.prototype={_claimActions:function(t){var e=this;this._actionNames=t?Object.keys(t):[],this._actionNames.forEach(function(n){if(e[n])throw Error(""+u+n+" is reserved for Domain interface");if("function"!=typeof t[n])throw Error(""+u+n+" action is not a function");e[n]=function(){for(var r=arguments.length,i=Array(r),u=0;r>u;u++)i[u]=arguments[u];(0,o.dispatchDomainAction)(t[n],e,i,1)}})},read:function(){return this.stream.read()},map:function(t){return this.stream.map(t)},debounce:function(t){return this.stream.debounce(t)},throttle:function(t){return this.stream.throttle(t)},subscribe:function(t){return this.stream.subscribe(t)},appendReactor:function(t){return this.stream.appendReactor(t)},destroy:function(){var t=this;this.stream.destroy(),this.stream=null,(0,o.rejectContext)(this),this._actionNames.forEach(function(e){t[e]=i}),this._actionNames=null}}},function(t,e){"use strict";function n(t){return t&&"undefined"!=typeof Symbol&&t.constructor===Symbol?"symbol":typeof t}function r(){for(var t=-1,e=null,n=0;m.length>n;n++){var r=m[n].priority;r>t&&(e=m[n],t=r)}return e}function o(){var t=r();return m.splice(m.indexOf(t),1),t}function i(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[],r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:g;m.push({priority:r,action:t,context:e,args:n})}function u(){p||m.length>0&&(p=!0,O.tick(function(){try{_()}catch(t){s(t)}p=!1,u()}))}function s(t){O.logger.error(v+"Error occured while running a function"),"object"===(void 0===t?"undefined":n(t))?t.stack?O.logger.error(t.stack):O.logger.error(t.name,t.message):O.logger.error(t)}function c(t,e,n,r){i(t,e,n,r),u()}function a(t,e,n){c(t,e,n,b)}function f(t,e,n){c(t,e,n,y)}function l(t,e,n){c(t,e,n,D)}function d(t,e,n){c(t,e,n,g)}function h(t){m=m.filter(function(e){return e.context!==t})}Object.defineProperty(e,"__esModule",{value:!0}),e.dispatch=c,e.dispatchDomainAction=a,e.dispatchDataWrite=f,e.dispatchDataConsume=l,e.dispatchExternal=d,e.rejectContext=h;var p=!1,m=[],v="Immview::Dispatcher: ",g=0,b=1,y=2,D=3,_=function(){var t=o();if(t){var e=t.context,n=t.action,r=t.args;n&&n.apply(e,r)}},O=e.Dispatcher={dispatch:d,tick:function(t){t()},rejectContext:h,logger:console};e.default=O},function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}function o(t){a.default.call(this),this.linkTo(null),this.digest((0,u.fromJS)(t))}var i=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t};Object.defineProperty(e,"__esModule",{value:!0}),e.default=o;var u=n(4),s=n(2),c=n(5),a=r(c);o.prototype=i({},a.default.prototype,{write:function(t){var e=this;(0,s.dispatchDataWrite)(function(){"function"==typeof t?e.consume(e.read(),t):e.consume(t)})}})},function(e,n){e.exports=t},function(t,e,n){"use strict";function r(t){return void 0!==t&&null!==t}function o(t,e){return r(e)&&(!r(t)||!(0,a.is)(e,t))}function i(t,e){var n=(0,f.createSchedule)(t);return(0,f.copyQueueOntoSchedule)(e,n)}function u(){(0,f.scheduleLength)(h)>0&&(h=(0,f.runScheduledPriorityJob)(h),(0,l.dispatchDataWrite)(u))}function s(t){return t}function c(){this.reactors=(0,a.Set)()}Object.defineProperty(e,"__esModule",{value:!0}),e.default=c;var a=n(4),f=n(6),l=n(2),d=[],h=[];c.prototype={read:function(){return this.structure},linkTo:function(t){d.push([t&&(t.stream?t.stream:t),this]),h=i(d,h)},unlink:function(){var t=this;d=d.filter(function(e){return e[0]!==t&&e[1]!==t}),h=i(d,h)},consume:function(t){var e=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:s;(0,l.dispatchDataConsume)(function(){h=(0,f.scheduleJob)(e,function(){return e.digest(n(t))},h),(0,l.dispatchDataWrite)(u)})},digest:function(t){o(this.structure,t)&&(this.structure=t,this.flush())},appendReactor:function(t){var e=this;return this.reactors=this.reactors.add(t),function(){e.reactors=e.reactors.delete(t)}},subscribe:function(t){return t(this.read()),this.appendReactor(t)},flush:function(){var t=this;this.reactors.forEach(function(e){return e(t.read())})},destroy:function(){this.unlink(),this.structure=null,this.reactors=(0,a.Set)()},map:function(t){var e=n(8).default;return new e(this,t)},debounce:function(t){var e=n(9).default;return new e(this,t)},throttle:function(t){var e=n(10).default;return new e(this,t)}}},function(t,e,n){"use strict";function r(t){return f(t).reduce(function(t,e){return t.unshift([e,null]),t},[])}function o(t,e,n){for(var r=[],o=0;n.length>o;o++){var i=n[o],u=i[0];r.push(u===t?[u,e]:i)}return r}function i(t){for(var e=0,n=0;t.length>n;n++)e+=0|!!t[n][1];return e}function u(t,e){for(var n=0;t.length>n;n++)if(t[n][0]===e)return t[n][1];return null}function s(t,e){for(var n=[].concat(e),r=0;t.length>r;r++){var o=t[r],i=o[0],u=o[1];if(u)for(var s=0;n.length>s;s++){var c=n[s],a=c[0];a===i&&(n[s]=o)}}return n}function c(t){for(var e=null,n=[].concat(t),r=0;t.length>r;r++){var o=t[r],i=o[0],u=o[1];u&&!e&&(e=u,n[r]=[i,null])}return e&&e(),n}Object.defineProperty(e,"__esModule",{value:!0}),e.sortStreamGraph=void 0,e.createSchedule=r,e.scheduleJob=o,e.scheduleLength=i,e.findJob=u,e.copyQueueOntoSchedule=s,e.runScheduledPriorityJob=c;var a=n(7),f=e.sortStreamGraph=a.getOrder},function(t,e){"use strict";function n(t){return t.reduce(function(t,e){return t.indexOf(e[0])<0&&t.push(e[0]),t.indexOf(e[1])<0&&t.push(e[1]),t},[])}function r(t){var e=[],r=[];return n(t).forEach(function(n){if(!e||e.indexOf(n)<0){var i=o(t,n,r,e);e=i.visited,r=i.stack}}),r}function o(t,e,n,r){var u=r.concat([e]),s=n;return i(t,e).forEach(function(e){if(!u||u.indexOf(e)<0){var n=o(t,e,s,u);u=n.visited,s=n.stack}}),{visited:u,stack:s.concat([e])}}function i(t,e){return t.filter(function(t){return t[0]===e}).map(function(t){return t[1]})}Object.defineProperty(e,"__esModule",{value:!0}),e.getGraphNodes=n,e.getOrder=r,e.visit=o,e.getNodeChildren=i},function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}function o(t){return t&&"undefined"!=typeof Symbol&&t.constructor===Symbol?"symbol":typeof t}function i(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:f;a.default.call(this),t&&"object"===(void 0===t?"undefined":o(t))&&(t.subscribe?this.connectToSource(t,e):this.connectToMultipleSources(t,e))}var u=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t};Object.defineProperty(e,"__esModule",{value:!0}),e.default=i;var s=n(4),c=n(5),a=r(c),f=function(t){return t};i.prototype=u({},a.default.prototype,{connectToSource:function(t,e){var n=this;this.linkTo(t),this.digest(e(t.read())),this.unsubs=[t.appendReactor(function(t){return n.digest(e(t))})]},connectToMultipleSources:function(t,e){var n=this,r=(0,s.Map)(),o=Object.keys(t);o.forEach(function(e){var o=t[e];n.linkTo(o);var i=o.read();r=r.set(e,i)}),this.unsubs=o.map(function(o){return t[o].appendReactor(function(t){r=r.set(o,t),n.consume(r,e)})}),this.digest(e(r))},destroy:function(){a.default.prototype.destroy.call(this),this.unsubs&&this.unsubs.forEach(function(t){return t()}),this.unsubs=null}})},function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}function o(t){var e=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;if(s.default.call(this),!t||!t.subscribe)throw Error(c+"incorrect source");this.linkTo(t),this.timeoutID=null,this.digest(t.read()),this.subscription=t.appendReactor(function(t){e.timeoutID&&clearTimeout(e.timeoutID),e.timeoutID=setTimeout(function(){e.timeoutID=null,e.consume(t)},n)})}var i=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t};Object.defineProperty(e,"__esModule",{value:!0}),e.default=o;var u=n(5),s=r(u),c="Immview::Debounce: ";o.prototype=i({},s.default.prototype,{destroy:function(){this.timeoutID&&(clearTimeout(this.timeoutID),this.timeoutID=null),this.subscription&&this.subscription(),s.default.prototype.destroy.call(this)}})},function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}function o(t){var e=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;if(s.default.call(this),!t||!t.subscribe)throw Error(c+"incorrect source");this.linkTo(t),this.timeoutID=null,this.timeoutedData=null,this.digest(t.read()),this.subscription=t.appendReactor(function(t){e.timeoutedData=t,e.timeoutID||(e.timeoutID=setTimeout(function(){e.timeoutID=null,e.consume(e.timeoutedData)},n))})}var i=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t};Object.defineProperty(e,"__esModule",{value:!0}),e.default=o;var u=n(5),s=r(u),c="Immview::Throttle: ";o.prototype=i({},s.default.prototype,{destroy:function(){this.timeoutID&&(clearTimeout(this.timeoutID),this.timeoutID=null),this.subscription&&this.subscription(),s.default.prototype.destroy.call(this)}})}])}); | ||
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("immutable")):"function"==typeof define&&define.amd?define(["immutable"],e):"object"==typeof exports?exports.immview=e(require("immutable")):t.immview=e(t.immutable)}(this,function(t){return function(t){function e(r){if(n[r])return n[r].exports;var o=n[r]={exports:{},id:r,loaded:!1};return t[r].call(o.exports,o,o.exports,e),o.loaded=!0,o.exports}var n={};return e.m=t,e.c=n,e.p="",e(0)}([function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}Object.defineProperty(e,"__esModule",{value:!0}),e.dispatch=e.Dispatcher=e.Throttle=e.Debounce=e.Domain=e.View=e.Data=void 0;var o=n(1),i=r(o),u=n(3),s=r(u),c=n(8),a=r(c),f=n(9),l=r(f),d=n(10),h=r(d),p=n(2),m=r(p),v=m.default.dispatch;e.Data=s.default,e.View=a.default,e.Domain=i.default,e.Debounce=l.default,e.Throttle=h.default,e.Dispatcher=m.default,e.dispatch=v},function(t,e,n){"use strict";function r(t,e){if(!t.subscribe)throw Error(u+" stream source required");this.stream=t,this._claimActions(e)}Object.defineProperty(e,"__esModule",{value:!0}),e.default=r;var o=n(2),i=function(){return null},u="Immview::Domain: ";r.prototype={_claimActions:function(t){var e=this;this._actionNames=t?Object.keys(t):[],this._actionNames.forEach(function(n){if(e[n])throw Error(""+u+n+" is reserved for Domain interface");if("function"!=typeof t[n])throw Error(""+u+n+" action is not a function");e[n]=function(){for(var r=arguments.length,i=Array(r),u=0;r>u;u++)i[u]=arguments[u];(0,o.dispatchDomainAction)(t[n],e,i,1)}})},read:function(){return this.stream.read()},map:function(t){return this.stream.map(t)},debounce:function(t){return this.stream.debounce(t)},throttle:function(t){return this.stream.throttle(t)},subscribe:function(t){return this.stream.subscribe(t)},appendReactor:function(t){return this.stream.appendReactor(t)},destroy:function(){var t=this;this.stream.destroy(),this.stream=null,(0,o.rejectContext)(this),this._actionNames.forEach(function(e){t[e]=i}),this._actionNames=null}}},function(t,e){"use strict";function n(t){return t&&"undefined"!=typeof Symbol&&t.constructor===Symbol?"symbol":typeof t}function r(){for(var t=-1,e=null,n=0;v.length>n;n++){var r=v[n].priority;r>t&&(e=v[n],t=r)}return e}function o(){var t=r();return v.splice(v.indexOf(t),1),t}function i(){var t=o();if(t){var e=t.context,n=t.action,r=t.args;n&&n.apply(e,r)}}function u(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[],r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:b;v.push({priority:r,action:t,context:e,args:n})}function s(){m||v.length>0&&(m=!0,O.tick(function(){try{i()}catch(t){c(t)}m=!1,s()}))}function c(t){O.logger.error(g+"Error occured while running a function"),"object"===(void 0===t?"undefined":n(t))?t.stack?O.logger.error(t.stack):O.logger.error(t.name,t.message):O.logger.error(t)}function a(t,e,n,r){u(t,e,n,r),s()}function f(t,e,n){a(t,e,n,y)}function l(t,e,n){a(t,e,n,D)}function d(t,e,n){a(t,e,n,_)}function h(t,e,n){a(t,e,n,b)}function p(t){v=v.filter(function(e){return e.context!==t})}Object.defineProperty(e,"__esModule",{value:!0}),e.dispatch=a,e.dispatchDomainAction=f,e.dispatchDataWrite=l,e.dispatchDataConsume=d,e.dispatchExternal=h,e.rejectContext=p;var m=!1,v=[],g="Immview::Dispatcher: ",b=0,y=1,D=2,_=3,O=e.Dispatcher={dispatch:h,tick:function(t){t()},rejectContext:p,logger:console};e.default=O},function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}function o(t){a.default.call(this),this.linkTo(null),this.digest((0,u.fromJS)(t))}var i=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t};Object.defineProperty(e,"__esModule",{value:!0}),e.default=o;var u=n(4),s=n(2),c=n(5),a=r(c);o.prototype=i({},a.default.prototype,{write:function(t){var e=this;(0,s.dispatchDataWrite)(function(){e.digest("function"==typeof t?t(e.read()):t)})}})},function(e,n){e.exports=t},function(t,e,n){"use strict";function r(t){return void 0!==t&&null!==t}function o(t,e){return r(e)&&(!r(t)||!(0,a.is)(e,t))}function i(t,e){var n=(0,f.createSchedule)(t);return(0,f.copyQueueOntoSchedule)(e,n)}function u(){(0,f.scheduleLength)(h)>0&&(h=(0,f.runScheduledPriorityJob)(h),(0,l.dispatchDataWrite)(u))}function s(t){return t}function c(){this.reactors=(0,a.Set)()}Object.defineProperty(e,"__esModule",{value:!0}),e.default=c;var a=n(4),f=n(6),l=n(2),d=[],h=[];c.prototype={read:function(){return this.structure},linkTo:function(t){d.push([t&&(t.stream?t.stream:t),this]),h=i(d,h)},unlink:function(){var t=this;d=d.filter(function(e){return e[0]!==t&&e[1]!==t}),h=i(d,h)},consume:function(t){var e=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:s;(0,l.dispatchDataConsume)(function(){h=(0,f.scheduleJob)(e,function(){return e.digest(n(t))},h),(0,l.dispatchDataWrite)(u)})},digest:function(t){o(this.structure,t)&&(this.structure=t,this.flush())},appendReactor:function(t){var e=this;return this.reactors=this.reactors.add(t),function(){e.reactors=e.reactors.delete(t)}},subscribe:function(t){return t(this.read()),this.appendReactor(t)},flush:function(){var t=this;this.reactors.forEach(function(e){return e(t.read())})},destroy:function(){this.unlink(),this.structure=null,this.reactors=(0,a.Set)()},map:function(t){var e=n(8).default;return new e(this,t)},debounce:function(t){var e=n(9).default;return new e(this,t)},throttle:function(t){var e=n(10).default;return new e(this,t)}}},function(t,e,n){"use strict";function r(t){return f(t).reduce(function(t,e){return t.unshift([e,null]),t},[])}function o(t,e,n){for(var r=[],o=0;n.length>o;o++){var i=n[o],u=i[0];r.push(u===t?[u,e]:i)}return r}function i(t){for(var e=0,n=0;t.length>n;n++)e+=0|!!t[n][1];return e}function u(t,e){for(var n=0;t.length>n;n++)if(t[n][0]===e)return t[n][1];return null}function s(t,e){for(var n=[].concat(e),r=0;t.length>r;r++){var o=t[r],i=o[0],u=o[1];if(u)for(var s=0;n.length>s;s++){var c=n[s],a=c[0];a===i&&(n[s]=o)}}return n}function c(t){for(var e=null,n=[].concat(t),r=0;t.length>r;r++){var o=t[r],i=o[0],u=o[1];if(u){e=u,n[r]=[i,null];break}}return e&&e(),n}Object.defineProperty(e,"__esModule",{value:!0}),e.sortStreamGraph=void 0,e.createSchedule=r,e.scheduleJob=o,e.scheduleLength=i,e.findJob=u,e.copyQueueOntoSchedule=s,e.runScheduledPriorityJob=c;var a=n(7),f=e.sortStreamGraph=a.getOrder},function(t,e){"use strict";function n(t){return t.reduce(function(t,e){return t.indexOf(e[0])<0&&t.push(e[0]),t.indexOf(e[1])<0&&t.push(e[1]),t},[])}function r(t){var e=[],r=[];return n(t).forEach(function(n){if(!e||e.indexOf(n)<0){var i=o(t,n,r,e);e=i.visited,r=i.stack}}),r}function o(t,e,n,r){var u=r.concat([e]),s=n;return i(t,e).forEach(function(e){if(!u||u.indexOf(e)<0){var n=o(t,e,s,u);u=n.visited,s=n.stack}}),{visited:u,stack:s.concat([e])}}function i(t,e){return t.filter(function(t){return t[0]===e}).map(function(t){return t[1]})}Object.defineProperty(e,"__esModule",{value:!0}),e.getGraphNodes=n,e.getOrder=r,e.visit=o,e.getNodeChildren=i},function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}function o(t){return t&&"undefined"!=typeof Symbol&&t.constructor===Symbol?"symbol":typeof t}function i(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:f;a.default.call(this),t&&"object"===(void 0===t?"undefined":o(t))&&(t.subscribe?this.connectToSource(t,e):this.connectToMultipleSources(t,e))}var u=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t};Object.defineProperty(e,"__esModule",{value:!0}),e.default=i;var s=n(4),c=n(5),a=r(c),f=function(t){return t};i.prototype=u({},a.default.prototype,{connectToSource:function(t,e){var n=this;this.linkTo(t),this.digest(e(t.read())),this.unsubs=[t.appendReactor(function(t){return n.consume(t,e)})]},connectToMultipleSources:function(t,e){var n=this,r=(0,s.Map)(),o=Object.keys(t);o.forEach(function(e){var o=t[e];n.linkTo(o);var i=o.read();r=r.set(e,i)}),this.unsubs=o.map(function(o){return t[o].appendReactor(function(t){r=r.set(o,t),n.consume(r,e)})}),this.digest(e(r))},destroy:function(){a.default.prototype.destroy.call(this),this.unsubs&&this.unsubs.forEach(function(t){return t()}),this.unsubs=null}})},function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}function o(t){var e=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;if(s.default.call(this),!t||!t.subscribe)throw Error(c+"incorrect source");this.linkTo(t),this.timeoutID=null,this.digest(t.read()),this.subscription=t.appendReactor(function(t){e.timeoutID&&clearTimeout(e.timeoutID),e.timeoutID=setTimeout(function(){e.timeoutID=null,e.consume(t)},n)})}var i=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t};Object.defineProperty(e,"__esModule",{value:!0}),e.default=o;var u=n(5),s=r(u),c="Immview::Debounce: ";o.prototype=i({},s.default.prototype,{destroy:function(){this.timeoutID&&(clearTimeout(this.timeoutID),this.timeoutID=null),this.subscription&&this.subscription(),s.default.prototype.destroy.call(this)}})},function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}function o(t){var e=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;if(s.default.call(this),!t||!t.subscribe)throw Error(c+"incorrect source");this.linkTo(t),this.timeoutID=null,this.timeoutedData=null,this.digest(t.read()),this.subscription=t.appendReactor(function(t){e.timeoutedData=t,e.timeoutID||(e.timeoutID=setTimeout(function(){e.timeoutID=null,e.consume(e.timeoutedData)},n))})}var i=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t};Object.defineProperty(e,"__esModule",{value:!0}),e.default=o;var u=n(5),s=r(u),c="Immview::Throttle: ";o.prototype=i({},s.default.prototype,{destroy:function(){this.timeoutID&&(clearTimeout(this.timeoutID),this.timeoutID=null),this.subscription&&this.subscription(),s.default.prototype.destroy.call(this)}})}])}); | ||
//# sourceMappingURL=immview.js.map |
{ | ||
"name": "immview", | ||
"version": "1.5.1", | ||
"version": "1.5.2", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "dist/immview.js", |
252
readme.md
@@ -21,31 +21,2 @@ # immview 1.5 | ||
## Simple down stream example | ||
```javascript | ||
// immview has no default export | ||
import { Data, View } from 'immview'; | ||
import { fromJS } from 'immutable'; | ||
var sourceStream = new Data(fromJS({ a: 1 })); | ||
var derivativeStream = new View( | ||
sourceStream, | ||
data => data.set('b', 2) | ||
); | ||
console.log(sourceStream.toJS()); | ||
// {a: 1} | ||
console.log(derivativeStream.toJS()); | ||
// {a: 1, b: 2} | ||
/** A CHANGE! */ | ||
sourceStream.write(data => data.set('a', 666)); | ||
console.log(sourceStream.toJS()); | ||
// {a: 666} | ||
console.log(derivativeStream.toJS()); | ||
// ..but a derivative data changed as well | ||
// {a: 666, b: 2} | ||
``` | ||
## Presentation | ||
@@ -55,219 +26,6 @@ | ||
#Docs | ||
## Data | ||
```javascript | ||
import {Data} from 'immview'; | ||
new Data( initialData: Immutable ) | ||
``` | ||
An **initialData** object can be object any Immutable.js data structure. | ||
###read() => Immutable | ||
Method used to retrieve current structure holden by the Data. | ||
```javascript | ||
//Example | ||
const source = new Data(fromJS({a: 1})); | ||
source.read().get('a'); // = 1 | ||
``` | ||
### write(change: Immutable ) => void | ||
### write(change: (currentStructure) => Immutable) => void | ||
Method used to store new Immutable data structure. | ||
**change** parameter: | ||
- is any Immutable data structure that should replace current one. If passed value is either undefined or null, replacement will not occur... | ||
- ...or a function that should return Immutable data structure that should replace current one. If function returns undefined or null, replacement will not occur. | ||
This function will not return changed structure so chaining will not be possible. It is because if this the change is requested during inside queued function (another *write* call or a **Domain** command), it will be postponed and executed after all currently queued commands. You should never presume timing of write execution. | ||
```javascript | ||
const source = new Data(fromJS({a: 1})); | ||
source.write(fromJS({a: 2})); | ||
source.write(data => data.set('b', 3)); | ||
``` | ||
### subscribe( reaction: (data: Immutable) => void ) => () => void | ||
Registers a function called every time when the Data changes value that it holds. Returns a function to unregister the subscription. | ||
### map( processor: (data: Immutable) => Immutable ) => View (since 1.4) | ||
Creates new **View** with the **Data** instance as a data source and **processor** as transformer function. **Processor** function will receive Immutable data structure and should be returned Immutable data structure too. | ||
### debounce( timeout: number ) => Debounce (since 1.5) | ||
Creates a new stream of values being pushed with a provided delay since last update. | ||
### throttle( timeout: number ) => Throttle (since 1.5) | ||
Creates a new stream of values being push with a provided delay since first update. | ||
## View | ||
```javascript | ||
import {View} from 'immview'; | ||
// duplicate source | ||
new View ( sourceDataProvider: Stream ) | ||
// join sources into a Map | ||
new View ( sourceDataProvider: { [string]: Stream } ) | ||
// transform source with processor function | ||
new View ( | ||
sourceDataProvider: Stream, | ||
processor: (sourceData: Immutable) => Immutable | ||
) | ||
// join sources into a Map and transform it with processor function | ||
new View ( | ||
sourceDataProvider: { [string]: Stream } , | ||
processor: (sourceData: Immutable) => Immutable | ||
) | ||
``` | ||
Constructor of **View** object takes any source (a stream or a **Domain**) as first argument and optionally function transforming this data as a second argument. | ||
A processor function will receive an Immutable data structure and its result must be any Immutable.js data structure. Returning Null or undefined will result in no subscription being fired. | ||
### read() => Immutable | ||
Method used to retrieve current structure holden by the View. | ||
### subscribe( reaction: (data) => void ) => () => void | ||
Registers a function called every time when the View changes value that it holds. Returns a function to unregister the subscription. | ||
### map( processor: (sourceData: Immutable) => Immutable ) => View (since 1.4) | ||
Creates new View with current instance as a data source and **processor** as transformer function. **Processor** function will receive Immutable data structure and should be returned Immutable data structure too. | ||
### debounce( timeout: number ) => Debounce (since 1.5) | ||
Creates a new stream of values being pushed with a provided delay since last update. | ||
### throttle( timeout: number ) => Throttle (since 1.5) | ||
Creates a new stream of values being push with a provided delay since first update. | ||
## Domain | ||
```javascript | ||
new Domain ( source: Stream ) | ||
new Domain ( source: Stream , { [string]: () => void } ) | ||
``` | ||
First argument of constructor is a data source. That will be a *state* stream of the newly created **Domain**. Only single data source can be tied to it, so **Domain** can be used as data source. | ||
Second argument is an object aggregating functions used to create commands that will be exposed as part of the **Domain** interface. These functions will be wrapped with an internal Dispatcher calls. **Domain** *actions* won't be returning anything and will be executed in call order, **one after another** even if *actions* calls are done from another *action* call. | ||
```javascript | ||
// example usage | ||
import {Data, View, Domain} from 'immview'; | ||
const EyesDomain = new Domain( | ||
new View({ | ||
HorizonDomain, | ||
MusclesDomain, | ||
}), | ||
{ | ||
roll() { | ||
MusclesDomain.doStuff(); | ||
} | ||
} | ||
); | ||
EyesDomain.roll(); | ||
``` | ||
### read() => Immutable (since 1.2) | ||
Method used to retrieve current Domain's *state*. | ||
> Although **Domain** can be created using **Data**, Domain won't be having **write** method available to discourage writing directly from dependent instances. | ||
### subscribe( reaction: (data) => void ) => () => void (since 1.2) | ||
Registers a function called every time when the Domain's *state* changes. Returns a function to unsubscribe from updates. | ||
### map( processor: (sourceData: Immutable) => Immutable ) => View (since 1.4) | ||
Creates new View with the Domain instance source as a data source and **processor** as transformer function. **Processor** function will receive Immutable data structure and should be returned Immutable data structure too. | ||
### debounce( timeout: number ) => Debounce (since 1.5) | ||
Creates a new stream of values being pushed with a provided delay since last update. | ||
### throttle( timeout: number ) => Throttle (since 1.5) | ||
Creates a new stream of values being push with a provided delay since first update. | ||
## Debounce, Throttle | ||
These share interface with a **View**. | ||
## Dispatcher | ||
### Dispatcher.logger (since 1.5) | ||
Replace to change for logging errors in queue runner | ||
(default: console) | ||
### Dispatcher.tick (since 1.5) | ||
Replace to change how next function is being called. | ||
default: | ||
``` | ||
func => func() | ||
``` | ||
### Dispatcher.dispatch( action: function, context: any, args: Array<any> ) (since 1.5) | ||
Call to place action on a queue. Can be imported directly from package too. | ||
``` | ||
import { dispatch } from 'immview'; | ||
``` | ||
### Dispatcher.rejectContext( context: any ) (since 1.5) | ||
Call to remove actions with provided context from queue. | ||
##Changelog | ||
###1.5.1 | ||
- fix: support for deferring ticker replacements | ||
###1.5 | ||
- feat: `Data` writes are prioritized over Domain actions | ||
- feat: streams are sorted so nodes are waiting with their updates for their dependencies are resolved | ||
- feat: `Debounce` and *.debounce() added | ||
- feat: `Throttle` and *.throttle() added | ||
- feat: `Dispatcher` is exposed now | ||
- feat: `dispatch` function is directly exposed by package for convenience | ||
- feat: guaranteed to work in node | ||
###1.4.2 | ||
- fix: `Queue` (dispatcher) returns stack trace instead of just error message | ||
### 1.4.1 | ||
- fix: broken contract - `View` could not be created from a domain as a source | ||
### 1.4.0 | ||
- fix: merged views processors will receive already fully merged source at first run | ||
- feat: *.map function on all classes | ||
- removed Immutable.Iterable functions from `Data` to promote read & write functions | ||
### 1.3.0 | ||
- read & write methods | ||
### 1.2.2 | ||
- `Data` exposes Immutable.Set functions too | ||
### 1.2.1 | ||
- uglify dist version | ||
### 1.2.0 | ||
- `Domain` and `Queue` have been added | ||
# Read more | ||
* [Reactive logic with immview](https://medium.com/@arturkulig/reactive-logic-with-immview-cf60ff06b7dc) - an introduction to reasoning behind immview | ||
* [Documentation](./docs.md) | ||
* [Simple usage](./usage_simple.md) | ||
* [Changelog](./changelog.md) |
@@ -24,5 +24,5 @@ import { | ||
if (typeof change === 'function') { | ||
this.consume(this.read(), change); | ||
this.digest(change(this.read())); | ||
} else { | ||
this.consume(change); | ||
this.digest(change); | ||
} | ||
@@ -29,0 +29,0 @@ }); |
@@ -35,3 +35,3 @@ let isRunning = false; | ||
*/ | ||
const runFirstQueuedItem = () => { | ||
function runFirstQueuedItem() { | ||
const task = shiftFromQueue(); | ||
@@ -38,0 +38,0 @@ if (task) { |
@@ -12,3 +12,3 @@ import { | ||
copyQueueOntoSchedule, | ||
} from './streamScheduler'; | ||
} from './StreamSchedule'; | ||
@@ -36,4 +36,4 @@ import { | ||
let digestLinks = []; | ||
let digestQueue = []; | ||
let digestEdges = []; | ||
let digestSchedule = []; | ||
@@ -46,4 +46,4 @@ function restoreNodeJobs(edges, currentSchedule) { | ||
function doNextJob() { | ||
if (scheduleLength(digestQueue) > 0) { | ||
digestQueue = runScheduledPriorityJob(digestQueue); | ||
if (scheduleLength(digestSchedule) > 0) { | ||
digestSchedule = runScheduledPriorityJob(digestSchedule); | ||
dispatchDataWrite(doNextJob); | ||
@@ -70,12 +70,12 @@ } | ||
linkTo(sourceNode) { | ||
digestLinks.push([ | ||
digestEdges.push([ | ||
sourceNode && (sourceNode.stream ? sourceNode.stream : sourceNode), | ||
this, | ||
]); | ||
digestQueue = restoreNodeJobs(digestLinks, digestQueue); | ||
digestSchedule = restoreNodeJobs(digestEdges, digestSchedule); | ||
}, | ||
unlink() { | ||
digestLinks = digestLinks.filter(link => link[0] !== this && link[1] !== this); | ||
digestQueue = restoreNodeJobs(digestLinks, digestQueue); | ||
digestEdges = digestEdges.filter(link => link[0] !== this && link[1] !== this); | ||
digestSchedule = restoreNodeJobs(digestEdges, digestSchedule); | ||
}, | ||
@@ -85,3 +85,3 @@ | ||
dispatchDataConsume(() => { | ||
digestQueue = scheduleJob(this, () => this.digest(chew(data)), digestQueue); | ||
digestSchedule = scheduleJob(this, () => this.digest(chew(data)), digestSchedule); | ||
dispatchDataWrite(doNextJob); | ||
@@ -88,0 +88,0 @@ }); |
@@ -31,3 +31,3 @@ import { | ||
this.unsubs = [ | ||
source.appendReactor(data => this.digest(process(data))), | ||
source.appendReactor(data => this.consume(data, process)), | ||
]; | ||
@@ -34,0 +34,0 @@ }, |
@@ -15,2 +15,3 @@ import { Data, View, Domain } from '../src'; | ||
const branch3b = new View(branch3aDomain, d => d * 10000); | ||
const constantStream = new Data(2); | ||
const end = new View({ | ||
@@ -20,6 +21,8 @@ branch1, | ||
branch3b, | ||
constantStream, | ||
}, data => | ||
data.get('branch1') + | ||
data.get('branch2b') + | ||
data.get('branch3b') | ||
data.get('branch3b') + | ||
data.get('constantStream') | ||
); | ||
@@ -38,4 +41,4 @@ | ||
expect(hits).toBe(2); | ||
expect(output).toBe(20002220); | ||
expect(output).toBe(20002222); | ||
}); | ||
}); |
@@ -96,2 +96,14 @@ import Data from '../src/Data'; | ||
}); | ||
it('writes can still be queued up and all performed', () => { | ||
const a = new Data(0); | ||
const b = new Data(0); | ||
a.write(i => { | ||
b.write(i => i + 1); | ||
b.write(i => i + 1); | ||
return i + 1; | ||
}); | ||
expect(a.read()).toBe(1); | ||
expect(b.read()).toBe(2); | ||
}); | ||
}); |
@@ -85,5 +85,5 @@ import Domain from '../src/Domain'; | ||
testMethod2: () => { | ||
testVar += '2'; | ||
dmn.testMethod1(); | ||
dmn.destroy(); | ||
testVar += '2'; | ||
}, | ||
@@ -90,0 +90,0 @@ |
@@ -12,1 +12,2 @@ import './data.spec'; | ||
import './switchedTicker.spec'; | ||
import './classExtending'; |
@@ -44,2 +44,5 @@ import { | ||
expect(Dispatcher).toBeDefined(); | ||
expect(Dispatcher.dispatch).toBeDefined(); | ||
expect(Dispatcher.rejectContext).toBeDefined(); | ||
expect(Dispatcher.logger).toBeDefined(); | ||
}); | ||
@@ -46,0 +49,0 @@ it('dispatch', () => { |
@@ -8,3 +8,3 @@ import { | ||
copyQueueOntoSchedule, | ||
} from '../src/streamScheduler'; | ||
} from '../src/StreamSchedule'; | ||
@@ -11,0 +11,0 @@ const graph = [ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
140714
37
1661
30