Comparing version 1.6.0 to 1.6.1
##Changelog | ||
### 1.6.1 | ||
- fix: `Data` ignores write instructions raised after the node being destroyed | ||
### 1.6 | ||
@@ -7,7 +11,6 @@ | ||
- feat: Actions mounted on domain have additional property originalLength to indicate arguments amount of original action function | ||
- On the road to have Immutable.js as option: | ||
- fix: `Data` no longer *magically* transforms initial data provided in constructor to Immutable.js data structure | ||
- fix: `View` is merging different streams using plain objects instead of Immutable.js map | ||
#### On the road to have Immutable.js as option | ||
- fix: `Data` no longer *magically* transforms initial data provided in constructor to Immutable.js data structure | ||
- fix: `View` is merging different streams using plain objects instead of Immutable.js map | ||
### 1.5.2 | ||
@@ -14,0 +17,0 @@ |
@@ -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 u=n[r]={exports:{},id:r,loaded:!1};return t[r].call(u.exports,u,u.exports,e),u.loaded=!0,u.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.Scan=e.Throttle=e.Debounce=e.Domain=e.View=e.Data=void 0;var u=n(1),i=r(u),o=n(3),s=r(o),c=n(9),a=r(c),f=n(11),l=r(f),d=n(12),h=r(d),p=n(13),m=r(p),v=n(2);e.Data=s.default,e.View=a.default,e.Domain=i.default,e.Debounce=l.default,e.Throttle=h.default,e.Scan=m.default,e.Dispatcher=v.Dispatcher,e.dispatch=v.dispatch},function(t,e,n){"use strict";function r(t,e){if(!t.subscribe)throw Error(s+" stream source required");this.stream=t,u(this,e)}function u(t,e){if(!e)return void(t.actions=function(){return[]});var n=Object.keys(e);n.forEach(function(n){var r=e[n];if(void 0!==t[n])throw Error(""+s+n+" is reserved for Domain interface");if("function"!=typeof r)throw Error(""+s+n+" action is not a function");t[n]=function(){for(var e=arguments.length,n=Array(e),u=0;e>u;u++)n[u]=arguments[u];(0,i.dispatchDomainAction)(r,t,n)},t[n].originalLength=r.length||r.originalLength}),t._actionNames=n,t.actions=function(){return n}}Object.defineProperty(e,"__esModule",{value:!0}),e.default=r;var i=n(2),o=function(){return null},s="Immview::Domain: ";r.prototype={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)},scan:function(t,e){return this.stream.scan(t,e)},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,i.rejectContext)(this),this._actionNames.forEach(function(e){t[e]=o}),this._actionNames=null}}},function(t,e){"use strict";function n(t){return t&&"undefined"!=typeof Symbol&&t.constructor===Symbol?"symbol":typeof t}function r(){var t=u();if(t){var e=t.context,n=t.action,r=t.args;n&&n.apply(e,r)}}function u(){var t=i();return v.splice(v.indexOf(t),1),t}function i(){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(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]:y;v.push({priority:r,action:t,context:e,args:n})}function s(t,e,n){l(t,e,n,b)}function c(t,e,n){l(t,e,n,_)}function a(t,e,n){l(t,e,n,O)}function f(t,e,n){l(t,e,n,y)}function l(t,e,n,r){o(t,e,n,r),d()}function d(){m||v.length>0&&(m=!0,D.tick(function(){try{r()}catch(t){h(t)}m=!1,d()}))}function h(t){D.logger.error(g+"Error occured while running a function"),"object"===(void 0===t?"undefined":n(t))?t.stack?D.logger.error(t.stack):D.logger.error(t.name,t.message):D.logger.error(t)}function p(t){v=v.filter(function(e){return e.context!==t})}Object.defineProperty(e,"__esModule",{value:!0});var m=!1,v=[],g="Immview::Dispatcher: ",y=0,b=1,_=2,O=3,D={dispatch:f,tick:function(t){t()},rejectContext:p,logger:console};e.default=D,e.Dispatcher=D,e.dispatch=l,e.dispatchDomainAction=s,e.dispatchDataWrite=c,e.dispatchDataConsume=a,e.dispatchExternal=f,e.rejectContext=p},function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}function u(t){s.default.call(this),this._linkTo(null),this._digest(t)}Object.defineProperty(e,"__esModule",{value:!0}),e.default=u;var i=n(2),o=n(4),s=r(o);u.prototype=Object.create(s.default.prototype),u.prototype.write=function(t){var e=this;(0,i.dispatchDataWrite)(function(){e._digest("function"==typeof t?t(e.read()):t)})}},function(t,e,n){"use strict";function r(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e.default=t,e}function u(){this._reactors=[]}function i(t,e){return o(e)&&(!o(t)||!(0,c.is)(e,t))}function o(t){return void 0!==t&&null!==t}function s(t){return t}Object.defineProperty(e,"__esModule",{value:!0}),e.default=u;var c=n(5),a=n(6),f=r(a);u.prototype={read:function(){return this.structure},_linkTo:function(t){f.link(t&&(t.stream?t.stream:t),this)},_unlink:function(){f.unlink(this)},_consume:function(t){var e=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:s;f.queue(this,function(){return e._digest(n(t))})},_digest:function(t){i(this.structure,t)&&(this.structure=t,this._flush(t))},_flush:function(t){this._reactors.forEach(function(e){return e(t)})},appendReactor:function(t){var e=this;return this._reactors.indexOf(t)<0&&this._reactors.push(t),function(){e._reactors=e._reactors.filter(function(e){return e!==t})}},subscribe:function(t){return t(this.read()),this.appendReactor(t)},destroy:function(){this._unlink(),this.structure=null,this._reactors=[]},map:function(t){var e=n(9).default;return new e(this,t)},debounce:function(t){var e=n(11).default;return new e(this,t)},throttle:function(t){var e=n(12).default;return new e(this,t)},scan:function(t,e){var r=n(13).default;return new r(this,t,e)}}},function(e,n){e.exports=t},function(t,e,n){"use strict";function r(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e.default=t,e}function u(t,e){a(c().concat([[t,e]]))}function i(t){a(c().filter(function(e){var n=p(e,2),r=n[0],u=n[1];return r!==t&&u!==t}))}function o(t,e){(0,g.dispatchDataConsume)(function(){h(v.scheduleJob(t,e,d())),s()})}function s(){(0,g.dispatchDataWrite)(l)}function c(){return y}function a(t){y=t,h(f(y,d()))}function f(t,e){var n=v.createSchedule(t);return v.copyQueueOntoSchedule(e,n)}function l(){v.scheduleLength(d())>0&&(h(v.runScheduledPriorityJob(d())),(0,g.dispatchDataWrite)(l))}function d(){return b}function h(t){b=t}var p=function(){function t(t,e){var n=[],r=!0,u=!1,i=void 0;try{for(var o,s=t[Symbol.iterator]();!(r=(o=s.next()).done)&&(n.push(o.value),!e||n.length!==e);r=!0);}catch(c){u=!0,i=c}finally{try{!r&&s.return&&s.return()}finally{if(u)throw i}}return n}return function(e,n){if(Array.isArray(e))return e;if(Symbol.iterator in Object(e))return t(e,n);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}();Object.defineProperty(e,"__esModule",{value:!0}),e.link=u,e.unlink=i,e.queue=o;var m=n(7),v=r(m),g=n(2),y=[],b=[]},function(t,e,n){"use strict";function r(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e.default=t,e}function u(t){return l.getOrder(t).reduce(function(t,e){return t.unshift([e,null]),t},[])}function i(t,e,n){for(var r=[],u=0;n.length>u;u++){var i=n[u],o=i[0];r.push(o===t?[o,e]:i)}return r}function o(t){for(var e=0,n=0;t.length>n;n++)e+=0|!!t[n][1];return e}function s(t,e){for(var n=0;t.length>n;n++)if(t[n][0]===e)return t[n][1];return null}function c(t,e){for(var n=[].concat(e),r=0;t.length>r;r++){var u=t[r],i=u[0],o=u[1];if(o)for(var s=0;n.length>s;s++){var c=n[s],a=c[0];a===i&&(n[s]=u)}}return n}function a(t){for(var e=null,n=[].concat(t),r=0;t.length>r;r++){var u=t[r],i=u[0],o=u[1];if(o){e=o,n[r]=[i,null];break}}return e&&e(),n}Object.defineProperty(e,"__esModule",{value:!0}),e.createSchedule=u,e.scheduleJob=i,e.scheduleLength=o,e.findJob=s,e.copyQueueOntoSchedule=c,e.runScheduledPriorityJob=a;var f=n(8),l=r(f)},function(t,e){"use strict";function n(t){var e=r(t).reduce(function(e,n){return i(e.visited,n)?e:u(t,n,e)},{visited:[],stack:[]});return e.stack}function r(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 u(t,e,n){var r=o(t,e).reduce(function(e,n){return i(e.visited,n)?e:u(t,n,e)},{visited:n.visited.concat([e]),stack:n.stack}),s={visited:r.visited,stack:r.stack.concat([e])};return s}function i(t,e){return t.indexOf(e)>=0}function o(t,e){return t.filter(function(t){return t[0]===e}).map(function(t){return t[1]})}Object.defineProperty(e,"__esModule",{value:!0}),e.getOrder=n,e.getAllNodes=r,e.getOrderStartingFromNode=u,e.getNodeChildren=o},function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}function u(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]:o;if(d.default.call(this),t&&"object"===(void 0===t?"undefined":u(t)))return void(this.unsubs=t.subscribe?s(this,t,e):c(this,t,e));throw Error(h+"No sources to plug in")}function o(t){return t}function s(t,e,n){return t._linkTo(e),t._digest(n(e.read())),[e.appendReactor(function(e){return t._consume(e,n)})]}function c(t,e,n){var r=new f.default,u=Object.keys(e);u.forEach(function(n){var u=e[n];t._linkTo(u);var i=u.read();r=r.set(n,i)});var i=u.map(function(u){return e[u].appendReactor(function(e){r=r.set(u,e),t._consume(r.clone(),n)})});return t._digest(n(r.clone())),i}Object.defineProperty(e,"__esModule",{value:!0}),e.default=i;var a=n(10),f=r(a),l=n(4),d=r(l),h="Immview::View: ";i.prototype=Object.create(d.default.prototype),i.prototype.destroy=function(){d.default.prototype.destroy.call(this),this.unsubs&&this.unsubs.forEach(function(t){return t()}),this.unsubs=null}},function(t,e){"use strict";function n(t){return Array.isArray(t)?t:Array.from(t)}function r(t){return t&&"undefined"!=typeof Symbol&&t.constructor===Symbol?"symbol":typeof t}function u(t){for(var e in t)Object.prototype.hasOwnProperty.call(t,e)&&(this[e]=t[e])}Object.defineProperty(e,"__esModule",{value:!0}),e.default=u,u.prototype={clone:function(){return new u(this)},set:function(t,e){var n=new u(this);return n[t]=e,n},get:function(t){return this[t]},map:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this,n=new u;for(var r in this)Object.prototype.hasOwnProperty.call(this,r)&&(n[r]=t.call(e,this[r]));return n},toJS:function(){return this.map(function(t){return"object"===(void 0===t?"undefined":r(t))&&"function"==typeof t.toJS?t.toJS():t})},toObject:function(){return this},getIn:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],e=n(t),r=e[0],u=e.slice(1),i=arguments[1];return u.length?this.get(r).getIn(u,i):void 0===this.get(r)?i:this.get(r)},setIn:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],e=n(t),r=e[0],i=e.slice(1),o=arguments[1];return i.length?this.set(r,(this.get(r)||new u).setIn(i,o)):this.set(r,o)}}},function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}function u(t){var e=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;if(o.default.call(this),!t||!t.subscribe)throw Error(s+"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)})}Object.defineProperty(e,"__esModule",{value:!0}),e.default=u;var i=n(4),o=r(i),s="Immview::Debounce: ";u.prototype=Object.create(o.default.prototype),u.prototype.destroy=function(){this.timeoutID&&(clearTimeout(this.timeoutID),this.timeoutID=null),this.subscription&&this.subscription(),o.default.prototype.destroy.call(this)}},function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}function u(t){var e=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;if(o.default.call(this),!t||!t.subscribe)throw Error(s+"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))})}Object.defineProperty(e,"__esModule",{value:!0}),e.default=u;var i=n(4),o=r(i),s="Immview::Throttle: ";u.prototype=Object.create(o.default.prototype),u.prototype.destroy=function(){this.timeoutID&&(clearTimeout(this.timeoutID),this.timeoutID=null),this.subscription&&this.subscription(),o.default.prototype.destroy.call(this)}},function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}function u(t){var e=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:2,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;c.default.apply(this),this._linkTo(t);var u=o(i(r,n),n,t.read());this._digest(u),this.unsubscribe=t.appendReactor(function(t){u=o(u,n,t),e._consume(u)})}function i(t,e){if(null===t)return[];for(var n=[],r=0;e>r;r++)n.push(t);return n}function o(t,e,n){var r=t.slice(-1*e+1);return r.push(n),r}Object.defineProperty(e,"__esModule",{value:!0}),e.default=u;var s=n(4),c=r(s);u.prototype=Object.create(c.default.prototype),u.prototype.read=function(){return[].concat(c.default.prototype.read.apply(this))},u.prototype.destroy=function(){c.default.prototype.destroy.apply(this),this.unsubscribe&&(this.unsubscribe(),this.unsubscribe=null)}}])}); | ||
!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 u=n[r]={exports:{},id:r,loaded:!1};return t[r].call(u.exports,u,u.exports,e),u.loaded=!0,u.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.Scan=e.Throttle=e.Debounce=e.Domain=e.View=e.Data=void 0;var u=n(1),i=r(u),o=n(3),s=r(o),c=n(9),a=r(c),f=n(11),l=r(f),d=n(12),h=r(d),p=n(13),m=r(p),v=n(2);e.Data=s.default,e.View=a.default,e.Domain=i.default,e.Debounce=l.default,e.Throttle=h.default,e.Scan=m.default,e.Dispatcher=v.Dispatcher,e.dispatch=v.dispatch},function(t,e,n){"use strict";function r(t,e){if(!t.subscribe)throw Error(s+" stream source required");this.stream=t,u(this,e)}function u(t,e){if(!e)return void(t.actions=function(){return[]});var n=Object.keys(e);n.forEach(function(n){var r=e[n];if(void 0!==t[n])throw Error(""+s+n+" is reserved for Domain interface");if("function"!=typeof r)throw Error(""+s+n+" action is not a function");t[n]=function(){for(var e=arguments.length,n=Array(e),u=0;e>u;u++)n[u]=arguments[u];(0,i.dispatchDomainAction)(r,t,n)},t[n].originalLength=r.length||r.originalLength}),t._actionNames=n,t.actions=function(){return n}}Object.defineProperty(e,"__esModule",{value:!0}),e.default=r;var i=n(2),o=function(){return null},s="Immview::Domain: ";r.prototype={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)},scan:function(t,e){return this.stream.scan(t,e)},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,i.rejectContext)(this),this._actionNames.forEach(function(e){t[e]=o}),this._actionNames=null}}},function(t,e){"use strict";function n(t){return t&&"undefined"!=typeof Symbol&&t.constructor===Symbol?"symbol":typeof t}function r(){var t=u();if(t){var e=t.context,n=t.action,r=t.args;n&&n.apply(e,r)}}function u(){var t=i();return v.splice(v.indexOf(t),1),t}function i(){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(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]:y;v.push({priority:r,action:t,context:e,args:n})}function s(t,e,n){l(t,e,n,b)}function c(t,e,n){l(t,e,n,_)}function a(t,e,n){l(t,e,n,O)}function f(t,e,n){l(t,e,n,y)}function l(t,e,n,r){o(t,e,n,r),d()}function d(){m||v.length>0&&(m=!0,D.tick(function(){try{r()}catch(t){h(t)}m=!1,d()}))}function h(t){D.logger.error(g+"Error occured while running a function"),"object"===(void 0===t?"undefined":n(t))?t.stack?D.logger.error(t.stack):D.logger.error(t.name,t.message):D.logger.error(t)}function p(t){v=v.filter(function(e){return e.context!==t})}Object.defineProperty(e,"__esModule",{value:!0});var m=!1,v=[],g="Immview::Dispatcher: ",y=0,b=1,_=2,O=3,D={dispatch:f,tick:function(t){t()},rejectContext:p,logger:console};e.default=D,e.Dispatcher=D,e.dispatch=l,e.dispatchDomainAction=s,e.dispatchDataWrite=c,e.dispatchDataConsume=a,e.dispatchExternal=f,e.rejectContext=p},function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}function u(t){s.default.call(this),this._linkTo(null),this._digest(t)}Object.defineProperty(e,"__esModule",{value:!0}),e.default=u;var i=n(2),o=n(4),s=r(o);u.prototype=Object.create(s.default.prototype),u.prototype.write=function(t){var e=this;(0,i.dispatchDataWrite)(function(){e.closed||e._digest("function"==typeof t?t(e.read()):t)},this)}},function(t,e,n){"use strict";function r(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e.default=t,e}function u(){this._reactors=[],this.closed=!1}function i(t,e){return o(e)&&(!o(t)||!(0,c.is)(e,t))}function o(t){return void 0!==t&&null!==t}function s(t){return t}Object.defineProperty(e,"__esModule",{value:!0}),e.default=u;var c=n(5),a=n(6),f=r(a),l=n(2),d=r(l);u.prototype={read:function(){return this.structure},_linkTo:function(t){f.link(t&&(t.stream?t.stream:t),this)},_unlink:function(){f.unlink(this)},_consume:function(t){var e=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:s;f.queue(this,function(){return e._digest(n(t))})},_digest:function(t){i(this.structure,t)&&(this.structure=t,this._flush(t))},_flush:function(t){this._reactors.forEach(function(e){return e(t)})},appendReactor:function(t){var e=this;return this._reactors.indexOf(t)<0&&this._reactors.push(t),function(){e._reactors=e._reactors.filter(function(e){return e!==t})}},subscribe:function(t){return t(this.read()),this.appendReactor(t)},destroy:function(){d.rejectContext(this),this._unlink(),this.structure=null,this._reactors=[],Object.defineProperty?Object.defineProperty(this,"closed",{value:!0,writable:!1}):this.closed=!0},map:function(t){var e=n(9).default;return new e(this,t)},debounce:function(t){var e=n(11).default;return new e(this,t)},throttle:function(t){var e=n(12).default;return new e(this,t)},scan:function(t,e){var r=n(13).default;return new r(this,t,e)}}},function(e,n){e.exports=t},function(t,e,n){"use strict";function r(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e.default=t,e}function u(t,e){a(c().concat([[t,e]]))}function i(t){a(c().filter(function(e){var n=p(e,2),r=n[0],u=n[1];return r!==t&&u!==t}))}function o(t,e){(0,g.dispatchDataConsume)(function(){h(v.scheduleJob(t,e,d())),s()})}function s(){(0,g.dispatchDataWrite)(l)}function c(){return y}function a(t){y=t,h(f(y,d()))}function f(t,e){var n=v.createSchedule(t);return v.copyQueueOntoSchedule(e,n)}function l(){v.scheduleLength(d())>0&&(h(v.runScheduledPriorityJob(d())),(0,g.dispatchDataWrite)(l))}function d(){return b}function h(t){b=t}var p=function(){function t(t,e){var n=[],r=!0,u=!1,i=void 0;try{for(var o,s=t[Symbol.iterator]();!(r=(o=s.next()).done)&&(n.push(o.value),!e||n.length!==e);r=!0);}catch(c){u=!0,i=c}finally{try{!r&&s.return&&s.return()}finally{if(u)throw i}}return n}return function(e,n){if(Array.isArray(e))return e;if(Symbol.iterator in Object(e))return t(e,n);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}();Object.defineProperty(e,"__esModule",{value:!0}),e.link=u,e.unlink=i,e.queue=o;var m=n(7),v=r(m),g=n(2),y=[],b=[]},function(t,e,n){"use strict";function r(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e.default=t,e}function u(t){return l.getOrder(t).reduce(function(t,e){return t.unshift([e,null]),t},[])}function i(t,e,n){for(var r=[],u=0;n.length>u;u++){var i=n[u],o=i[0];r.push(o===t?[o,e]:i)}return r}function o(t){for(var e=0,n=0;t.length>n;n++)e+=0|!!t[n][1];return e}function s(t,e){for(var n=0;t.length>n;n++)if(t[n][0]===e)return t[n][1];return null}function c(t,e){for(var n=[].concat(e),r=0;t.length>r;r++){var u=t[r],i=u[0],o=u[1];if(o)for(var s=0;n.length>s;s++){var c=n[s],a=c[0];a===i&&(n[s]=u)}}return n}function a(t){for(var e=null,n=[].concat(t),r=0;t.length>r;r++){var u=t[r],i=u[0],o=u[1];if(o){e=o,n[r]=[i,null];break}}return e&&e(),n}Object.defineProperty(e,"__esModule",{value:!0}),e.createSchedule=u,e.scheduleJob=i,e.scheduleLength=o,e.findJob=s,e.copyQueueOntoSchedule=c,e.runScheduledPriorityJob=a;var f=n(8),l=r(f)},function(t,e){"use strict";function n(t){var e=r(t).reduce(function(e,n){return i(e.visited,n)?e:u(t,n,e)},{visited:[],stack:[]});return e.stack}function r(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 u(t,e,n){var r=o(t,e).reduce(function(e,n){return i(e.visited,n)?e:u(t,n,e)},{visited:n.visited.concat([e]),stack:n.stack}),s={visited:r.visited,stack:r.stack.concat([e])};return s}function i(t,e){return t.indexOf(e)>=0}function o(t,e){return t.filter(function(t){return t[0]===e}).map(function(t){return t[1]})}Object.defineProperty(e,"__esModule",{value:!0}),e.getOrder=n,e.getAllNodes=r,e.getOrderStartingFromNode=u,e.getNodeChildren=o},function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}function u(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]:o;if(d.default.call(this),t&&"object"===(void 0===t?"undefined":u(t)))return void(this.unsubs=t.subscribe?s(this,t,e):c(this,t,e));throw Error(h+"No sources to plug in")}function o(t){return t}function s(t,e,n){return t._linkTo(e),t._digest(n(e.read())),[e.appendReactor(function(e){return t._consume(e,n)})]}function c(t,e,n){var r=new f.default,u=Object.keys(e);u.forEach(function(n){var u=e[n];t._linkTo(u);var i=u.read();r=r.set(n,i)});var i=u.map(function(u){return e[u].appendReactor(function(e){r=r.set(u,e),t._consume(r.clone(),n)})});return t._digest(n(r.clone())),i}Object.defineProperty(e,"__esModule",{value:!0}),e.default=i;var a=n(10),f=r(a),l=n(4),d=r(l),h="Immview::View: ";i.prototype=Object.create(d.default.prototype),i.prototype.destroy=function(){d.default.prototype.destroy.call(this),this.unsubs&&this.unsubs.forEach(function(t){return t()}),this.unsubs=null}},function(t,e){"use strict";function n(t){return Array.isArray(t)?t:Array.from(t)}function r(t){return t&&"undefined"!=typeof Symbol&&t.constructor===Symbol?"symbol":typeof t}function u(t){for(var e in t)Object.prototype.hasOwnProperty.call(t,e)&&(this[e]=t[e])}Object.defineProperty(e,"__esModule",{value:!0}),e.default=u,u.prototype={clone:function(){return new u(this)},set:function(t,e){var n=new u(this);return n[t]=e,n},get:function(t){return this[t]},map:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this,n=new u;for(var r in this)Object.prototype.hasOwnProperty.call(this,r)&&(n[r]=t.call(e,this[r]));return n},toJS:function(){return this.map(function(t){return"object"===(void 0===t?"undefined":r(t))&&"function"==typeof t.toJS?t.toJS():t})},toObject:function(){return this},getIn:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],e=n(t),r=e[0],u=e.slice(1),i=arguments[1];return u.length?this.get(r).getIn(u,i):void 0===this.get(r)?i:this.get(r)},setIn:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],e=n(t),r=e[0],i=e.slice(1),o=arguments[1];return i.length?this.set(r,(this.get(r)||new u).setIn(i,o)):this.set(r,o)}}},function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}function u(t){var e=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;if(o.default.call(this),!t||!t.subscribe)throw Error(s+"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)})}Object.defineProperty(e,"__esModule",{value:!0}),e.default=u;var i=n(4),o=r(i),s="Immview::Debounce: ";u.prototype=Object.create(o.default.prototype),u.prototype.destroy=function(){this.timeoutID&&(clearTimeout(this.timeoutID),this.timeoutID=null),this.subscription&&this.subscription(),o.default.prototype.destroy.call(this)}},function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}function u(t){var e=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;if(o.default.call(this),!t||!t.subscribe)throw Error(s+"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))})}Object.defineProperty(e,"__esModule",{value:!0}),e.default=u;var i=n(4),o=r(i),s="Immview::Throttle: ";u.prototype=Object.create(o.default.prototype),u.prototype.destroy=function(){this.timeoutID&&(clearTimeout(this.timeoutID),this.timeoutID=null),this.subscription&&this.subscription(),o.default.prototype.destroy.call(this)}},function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}function u(t){var e=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:2,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;c.default.apply(this),this._linkTo(t);var u=o(i(r,n),n,t.read());this._digest(u),this.unsubscribe=t.appendReactor(function(t){u=o(u,n,t),e._consume(u)})}function i(t,e){if(null===t)return[];for(var n=[],r=0;e>r;r++)n.push(t);return n}function o(t,e,n){var r=t.slice(-1*e+1);return r.push(n),r}Object.defineProperty(e,"__esModule",{value:!0}),e.default=u;var s=n(4),c=r(s);u.prototype=Object.create(c.default.prototype),u.prototype.read=function(){return[].concat(c.default.prototype.read.apply(this))},u.prototype.destroy=function(){c.default.prototype.destroy.apply(this),this.unsubscribe&&(this.unsubscribe(),this.unsubscribe=null)}}])}); | ||
//# sourceMappingURL=immview.js.map |
{ | ||
"name": "immview", | ||
"version": "1.6.0", | ||
"version": "1.6.1", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "dist/immview.js", |
@@ -19,2 +19,5 @@ import { dispatchDataWrite } from './Dispatcher'; | ||
dispatchDataWrite(() => { | ||
if (this.closed) { | ||
return; | ||
} | ||
if (typeof change === 'function') { | ||
@@ -25,3 +28,3 @@ this._digest(change(this.read())); | ||
} | ||
}); | ||
}, this); | ||
}; |
@@ -107,3 +107,3 @@ let isRunning = false; | ||
* @param {Array.<*>} [args] | ||
* @param {number} [priority=0] priority for dispatched action. 0, 1, 2 are acceptable | ||
* @param {number} [priority=0] priority for dispatched action. | ||
*/ | ||
@@ -110,0 +110,0 @@ function dispatch(action, context, args, priority) { |
@@ -6,2 +6,3 @@ import { | ||
import * as Digest from './Digest'; | ||
import * as Dispatcher from './Dispatcher'; | ||
@@ -18,2 +19,7 @@ /** | ||
this._reactors = []; | ||
/** | ||
* @public | ||
* @type {boolean} | ||
*/ | ||
this.closed = false; | ||
} | ||
@@ -107,5 +113,9 @@ | ||
destroy() { | ||
Dispatcher.rejectContext(this); | ||
this._unlink(); | ||
this.structure = null; | ||
this._reactors = []; | ||
Object.defineProperty | ||
? Object.defineProperty(this, 'closed', { value: true, writable: false }) | ||
: this.closed = true; | ||
}, | ||
@@ -141,3 +151,3 @@ | ||
); | ||
}; | ||
} | ||
@@ -144,0 +154,0 @@ function hasValue(v) { |
import Data from '../src/Data'; | ||
import { dispatch } from '../src/Dispatcher'; | ||
import { | ||
@@ -162,2 +163,27 @@ Map, | ||
}); | ||
describe('can be destroyed', () => { | ||
it('and ignores writes', done => { | ||
const a = new Data(0); | ||
dispatch(() => { | ||
a.destroy(); | ||
a.write(1); | ||
}); | ||
dispatch(() => { | ||
expect(a.read()).toBe(null); | ||
}); | ||
dispatch(() => setTimeout(done, 0)); | ||
}); | ||
it('and rejects pending writes', done => { | ||
const a = new Data(0); | ||
dispatch(() => { | ||
a.write(1); | ||
a.destroy(); | ||
}); | ||
dispatch(() => { | ||
expect(a.read()).toBe(null); | ||
}); | ||
dispatch(() => setTimeout(done, 0)); | ||
}); | ||
}); | ||
}); |
Sorry, the diff of this file is not supported yet
180170
2052