Closed devmondo closed 8 years ago
Hi! It supports oldValues - however, they would become inconsistent due to "transactions",
For example
let obj = {
a: 0
};
for (var i = 0; i < 100; i++) {
obj.a++;
}
watch(obj, 'a', function(newVal, oldVal) {
});
Will give you 99 as an old value (You would expect 0 right?). Please feel free to suggest if you have some ideas on the matter.
thanks for the reply,
actually the example above dont run at all, i had to remove the for loop below the watch function, and it works fine and i get the correct old and new values, infact if i keep your example and just later modify the a prop like below i get correct old value as 100 and new value as 1111
let obj = {
a: 0
};
for (var i = 0; i < 100; i++) {
obj.a++;
}
watch(obj, 'a', function(newVal, oldVal) {
console.log(44444444,newVal, oldVal);
});
obj.a = 1111;
so i am lost if you could explain more :)
My bad, i am not really tracking old values there. (i did not put any efforts in testing those). Did not really think that anyone would need old values using async approach ;-) I will check it when i have time.
thank you :)
Hi! I have released a new version, that should fix few corner cases i encountered
If you i think it's all covered, we can close the issue =)
awesome mate i tested it and it works flawlessly so far :)
hi,
great work there, could we get old value in the call back ?
something like this
thanks in advanced.