You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
On function withProxyDependentObservable, the wrap function makes all computed writable.
Solution:
function withProxyDependentObservable(dependentObservables, callback) {
var localDO = ko.dependentObservable;
ko.dependentObservable = function (read, owner, options) {
options = options || {};
if (read && typeof read == "object") { // mirrors condition in knockout implementation of DO's
options = read;
}
var realDeferEvaluation = options.deferEvaluation;
var isRemoved = false;
// We wrap the original dependent observable so that we can remove it from the 'dependentObservables' list we need to evaluate after mapping has
// completed if the user already evaluated the DO themselves in the meantime.
var wrap = function (DO) {
var wrapped = realKoDependentObservable({
read: function () {
if (!isRemoved) {
ko.utils.arrayRemoveItem(dependentObservables, DO);
isRemoved = true;
}
return DO.apply(DO, arguments);
},
write: DO.hasWriteFunction && function (val) { // ***** HERE IS THE FIX *****
return DO(val);
},
deferEvaluation: true
});
if(DEBUG) wrapped._wrapper = true;
return wrapped;
};
options.deferEvaluation = true; // will either set for just options, or both read/options.
var realDependentObservable = new realKoDependentObservable(read, owner, options);
if (!realDeferEvaluation) {
realDependentObservable = wrap(realDependentObservable);
dependentObservables.push(realDependentObservable);
}
return realDependentObservable;
}
ko.dependentObservable.fn = realKoDependentObservable.fn;
ko.computed = ko.dependentObservable;
var result = callback();
ko.dependentObservable = localDO;
ko.computed = ko.dependentObservable;
return result;
}
The text was updated successfully, but these errors were encountered:
It looks like hasWriteFunction is considered part of the private API since it's mangled/obfuscated in the minified build. Replacing DO.hasWriteFunction with ko.isWriteableObservable(DO) should work in both the debug and minified builds.
On function withProxyDependentObservable, the wrap function makes all computed writable.
Solution:
function withProxyDependentObservable(dependentObservables, callback) {
var localDO = ko.dependentObservable;
ko.dependentObservable = function (read, owner, options) {
options = options || {};
The text was updated successfully, but these errors were encountered: