Skip to content
Browse files

Allow dependentObservables to be constructed during the mutation phase

  • Loading branch information...
1 parent ed1bb87 commit 79765f4abeeb87fce9ffca3c0c032229e18f28ab @beickhoff committed
View
2 build/output/knockout-latest.debug.js
@@ -827,7 +827,7 @@ ko.newAtomicObservableManager = function () {
statefulApi.dependentNodeAccessor = ko.abstractObservableManager.dependentNodeAccessor;
statefulApi.compositeMutationBroadcast = writePhaseCompositeMutationBroadcast;
statefulApi.rebindingBroadcast = null; // does not occur
- statefulApi.reevaluationBroadcast = null; // does not occur
+ statefulApi.reevaluationBroadcast = nullFn;
}
function writePhaseIndependentNodeAccessor(args) {
View
2 build/output/knockout-latest.js
@@ -29,7 +29,7 @@ p.ka=function(){var a=[];this.wa=function(){return a.slice(0)};this.la=function(
p.b("ko.subscribable",p.ka);p.b("ko.isSubscribable",p.xa);p.L=function(){var a=[];return{Sa:function(){a.push([])},end:function(){return a.pop()},Ba:function(e){p.xa(e)||b("Only subscribable things can act as dependencies");a.length>0&&a[a.length-1].push(e)}}}();p.J=function(){function a(){return""+e++}var e=0;return{next:a,ra:function(c){c.Ma=a()},ga:function(a){return a.Ma}}}();
p.m={r:function(a){return Object.prototype.hasOwnProperty.call(a,"newValue")?(a.pa(a)&&(a.g(a.newValue),a.T(a)),this):(p.L.Ba(a.f),a.g())},u:function(a){if(Object.prototype.hasOwnProperty.call(a,"valueToWrite"))typeof a.options.write==="function"?a.options.write.call(a.options.owner||o,a.wb):b("Cannot write a value to a dependentObservable unless you specify a 'write' option. If you wish to read the current value, don't pass any parameters.");else return a.na||a.evaluate(),p.L.Ba(a.k),a.g()},H:function(a){a.f.G(a.g())},
w:function(a){a.f.G(a.g())},I:function(a){a.f.G(a.g())}};p.qa={r:function(a){a=p.a.extend({},a);a.T=p.m.H;return p.m.r.call(this,a)},u:p.m.u,H:p.m.H,w:p.m.w,I:p.m.I};
-p.lb=function(){function a(){}function e(){j={};k=[];q=l=o;i.r=c;i.u=p.m.u;i.w=d;i.H=o;i.I=o}function c(c){var d=p.a.extend({},c);d.g=function(){var a=p.J.ga(c.f),d;if(arguments.length)d=p.a.extend({},c),d.newValue=arguments[0],j[a]=d;else return(d=Object.prototype.hasOwnProperty.call(j,a))?j[a].newValue:c.g()};d.T=a;return p.m.r.call(this,d)}function d(a){k.push(a)}function f(a){var c=p.a.extend({},a);c.pa=function(){n.push(a);return!1};return p.m.r.call(this,c)}function g(a){var c=p.J.ga(a.evaluate);
+p.lb=function(){function a(){}function e(){j={};k=[];q=l=o;i.r=c;i.u=p.m.u;i.w=d;i.H=o;i.I=a}function c(c){var d=p.a.extend({},c);d.g=function(){var a=p.J.ga(c.f),d;if(arguments.length)d=p.a.extend({},c),d.newValue=arguments[0],j[a]=d;else return(d=Object.prototype.hasOwnProperty.call(j,a))?j[a].newValue:c.g()};d.T=a;return p.m.r.call(this,d)}function d(a){k.push(a)}function f(a){var c=p.a.extend({},a);c.pa=function(){n.push(a);return!1};return p.m.r.call(this,c)}function g(a){var c=p.J.ga(a.evaluate);
if(!Object.prototype.hasOwnProperty.call(a,"valueToWrite")&&Object.prototype.hasOwnProperty.call(l,c)&&!Object.prototype.hasOwnProperty.call(q,c))q[c]=o,a=p.a.extend({},a),a.na=!1;return p.m.u(a)}function h(a){r.push(a)}var i,j,k,l,q,n,r;i={Ua:function(){function c(a){var e=a.g;p.a.e(a.f.wa(),function(a){var a=a.K,f=p.J.ga(a);f==o?d.push({K:a,g:e}):Object.prototype.hasOwnProperty.call(l,f)||(l[f]={evaluate:a},c({f:a.za,g:a.za}))})}var d=[];l={};p.a.ya(j,function(a,d){var e=p.a.extend({},d);e.T=c;
return p.m.r.call(this,e)});p.a.e(k,function(a){c(a)});q={};n=[];r=[];k=j=o;i.r=f;i.u=g;i.w=h;i.I=a;i.H=o;p.a.ya(l,function(a,c){Object.prototype.hasOwnProperty.call(q,a)||(q[a]=o,c.evaluate())});p.a.e(d,function(a){a.K(a.g())});if(n.length||r.length)return e(),function(){p.a.e(n,function(a){p.s.r(a)});p.a.e(r,function(a){p.s.w(a)})}}};e();return i};p.s=p.qa;p.xb=function(a){p.s=p.lb();try{do a(),a=p.s.Ua();while(a)}finally{p.s=p.qa}};var x={undefined:!0,"boolean":!0,number:!0,string:!0};
function y(a,e){return a===o||typeof a in x?a===e:!1}p.f=function(a){function e(){if(arguments.length)f=arguments[0];else return f}function c(){var a={f:c,g:e,pa:d};if(arguments.length)a.newValue=arguments[0];return p.s.r.call(this,a)}function d(a){var c=a.f.equalityComparer;return!c||!c(a.g(),a.newValue)}var f=a;p.J.ra(c);c.t=p.f;c.R=function(){p.s.w({f:c,g:e})};c.equalityComparer=y;p.ka.call(c);p.l(c,"valueHasMutated",c.R);return c};
View
6 spec/atomicUpdateBehaviors.js
@@ -377,6 +377,12 @@ describe("Atomic Updates", {
value_of(evaluationCount.A).should_be(1);
value_of(evaluationCount.B).should_be(1);
value_of(evaluationCount.C).should_be(2);
+ },
+
+ "Should not throw an exception if a dependentObservable is constructed during the mutation phase": function () {
+ ko.atomically(function () {
+ ko.dependentObservable(function () {});
+ });
}
});
View
2 src/subscribables/observableManager.js
@@ -94,7 +94,7 @@ ko.newAtomicObservableManager = function () {
statefulApi.dependentNodeAccessor = ko.abstractObservableManager.dependentNodeAccessor;
statefulApi.compositeMutationBroadcast = writePhaseCompositeMutationBroadcast;
statefulApi.rebindingBroadcast = null; // does not occur
- statefulApi.reevaluationBroadcast = null; // does not occur
+ statefulApi.reevaluationBroadcast = nullFn;
}
function writePhaseIndependentNodeAccessor(args) {

0 comments on commit 79765f4

Please sign in to comment.
Something went wrong with that request. Please try again.