Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

setInterval ~13 #78

Open
gre opened this issue May 15, 2016 · 11 comments
Open

setInterval ~13 #78

gre opened this issue May 15, 2016 · 11 comments

Comments

@gre
Copy link

gre commented May 15, 2016

shouldn't setInterval be wrapped as well?

@matthewp
Copy link
Contributor

Perhaps wrapped, but not wrapped and waited on.

@matthewp
Copy link
Contributor

Fair point though, it should still be run within the Zone.

@justinbmeyer
Copy link
Contributor

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 [email protected] 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

@matthewp
Copy link
Contributor

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.

@justinbmeyer
Copy link
Contributor

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 [email protected] 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

@matthewp
Copy link
Contributor

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);

@matthewp
Copy link
Contributor

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?

@justinbmeyer
Copy link
Contributor

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.

@matthewp
Copy link
Contributor

jQuery animate uses setInterval: #86

@matthewp matthewp added the p2 label Oct 17, 2016
@matthewp matthewp changed the title setInterval setInterval ~13 Oct 17, 2016
@mickmcgrath13
Copy link

Looks like jQuery ^3.2.0 uses rAF: jquery/jquery@6d43dc4

@frank-dspeed
Copy link
Contributor

i also use setInterval for polling

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants