Open gre opened 8 years ago
Perhaps wrapped, but not wrapped and waited on.
Fair point though, it should still be run within the Zone.
Perhaps waited on. It's possible someone starts an interval and then cancels it.
Sent from my iPhone
On May 20, 2016, at 6:24 AM, Matthew Phillips notifications@github.com wrote:
Perhaps wrapped, but not wrapped and waited on.
— You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub
We can't really detect that though. I think it's edge-casey enough to ignore, and people can always use Zone.waitFor
themselves for code like this.
Why can't we? We should be able to detect if someone calls clearTimeout or clearInterval
Sent from my iPhone
On May 20, 2016, at 9:20 AM, Matthew Phillips notifications@github.com wrote:
We can't really detect that though. I think it's edge-casey enough to ignore, and people can always use Zone.waitFor themselves for code like this.
— You are receiving this because you commented. Reply to this email directly or view it on GitHub
Ok so I think you mean code like this:
var id = setInterval(function(){ ... });
clearInterval(id);
Yes, I agree we can support this. We will need to check if it is cleared at end-of-turn or not.
I was thinking something like this, which I don't think we should attempt to detect:
var count = 0;
var id = setInterval(function(){
if(count === 5) {
clearInterval(id);
}
count++;
}, 500);
Actually, I'm confused, this scenario:
var id = setInterval(function(){ ... });
clearInterval(id);
We don't need to wait on this anyways. So what scenario that a setInterval is cleared that we should wait on?
I'm thinking about things like your previous example:
var count = 0;
var id = setInterval(function(){
if(count === 5) {
clearInterval(id);
}
count++;
}, 500);
Lots of animation libraries use setTimeout
/ clearTimeout
. Poorly written ones might use setInterval
clearInterval
.
Animations might run while the app is bootstrapping. Maybe someone is using setInterval
in some strange way to poll XHR (some ajax libraries polled XHR to avoid memory leaks).
My gut tells me to watch it by default, and then let people turn it off.
jQuery animate uses setInterval: https://github.com/canjs/can-zone/issues/86
Looks like jQuery ^3.2.0
uses rAF: https://github.com/jquery/jquery/commit/6d43dc42337089f5fb52b715981c12993f490920
i also use setInterval for polling
shouldn't setInterval be wrapped as well?