Open samad-aghaei opened 7 years ago
@samad-aghaei Hi! I guess that's related to requestAnimationFrame it's rather random ;-)
You could suggest an option where this one is setTimeout 0
@nchanged Thanks for your quick respond. Your'e right, the problem is requestAnimationFrame and I just replace line 3 with the following:
var nextTick = isNode ? process.nextTick : function(frame){return setTimeout(frame, 1000/60)}
It works, Anyway. But I believe that this is not a good solution.
I believe holding refresh interrupts the execution, and that's why you have inconsistent results
Some stuff happens asynchronously in the browser, even when you refresh! and they get queued by chrome itself. this is why you sometimes get different results.
I just got different result at different times on example below:
var obj = {}; // creating an empty object AsyncWatch(obj, 'a.b.c', function(value){ console.log('set', value); });
obj.a = { b : { c : 1 } }; obj.a.b.c = 2; obj.a.b.c = 3;
setTimeout(function(){ obj.a.b.c = 4; },10)
/** By holding "CTRL + R" in latest version of Chrome: //Sometimes the result is set 4
//Sometimes the result is set 4 set 4
//Sometimes the result is set 3 set 4
//Sometimes the result is set 3