javascript - Change observable but don't notify subscribers in knockout.js -
is there way ignore subscribers on value change of observable. id change value of observable, not execute subscribers knockout.js
normally not possible or advisable, potentially allows things out of sync in dependency chains. using throttle extender way limit amount of notifications dependencies receiving.
however, if want this, 1 option overwrite notifysubscribers
function on observable , have check flag.
here extensions adds functionality observable:
ko.observable.fn.withpausing = function() { this.notifysubscribers = function() { if (!this.pausenotifications) { ko.subscribable.fn.notifysubscribers.apply(this, arguments); } }; this.sneakyupdate = function(newvalue) { this.pausenotifications = true; this(newvalue); this.pausenotifications = false; }; return this; };
you add observable like:
this.name = ko.observable("bob").withpausing();
then update without notifications doing:
this.name.sneakyupdate("ted");
Comments
Post a Comment