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
function AppViewModel() {
this.key = ko.observable();
this.list = {};
}
var vm = new AppViewModel();
ko.options.deferUpdates = true;
ko.applyBindings(vm);
setTimeout(()=>vm.list["test"] = ko.observableArray(["apple", "orange"]),100);
setTimeout(()=>vm.key("test"), 200);
setTimeout(()=>{
vm.key.valueHasMutated();
vm.list['test'](["cat", "dog", "mice", "bird"]);
}, 300);
Expected Output after 300ms:
"cat", "dog", "mice", "bird" but is
"cat", "dog", "mice", "bird", "mice", "bird"
But works with "ko.options.deferUpdates = false;"
or without "vm.key.valueHasMutated();" before setting new list
or new list has same length as old list.
Anyway - thanks for the good job on knockout!
The text was updated successfully, but these errors were encountered:
I've got a table component which duplicates lines for no reason. My component life cycle looks like your example. I'm happy you was able to pinpoint the issue in a simple example.
By the way, your demo link is broken in the issue description.
Thx, I fixed the link in my description and I try to avoid valueHasMutated for now on.
In my project it was used to trigger some computed's who access other changed non-observable data; it seems to put them in an observable too would be a good choice anyway.
See: https://codepen.io/coyer/pen/zYRRqyo?editors=1010
HTML:
Script:
Expected Output after 300ms:
"cat", "dog", "mice", "bird"
but is
"cat", "dog", "mice", "bird", "mice", "bird"
But works with "ko.options.deferUpdates = false;"
or without "vm.key.valueHasMutated();" before setting new list
or new list has same length as old list.
Anyway - thanks for the good job on knockout!
The text was updated successfully, but these errors were encountered: