-
Notifications
You must be signed in to change notification settings - Fork 189
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
Separate delay for inactivity timeout #5
Comments
How would the code know the difference between when to use the 250ms "throttle" behavior and the 50ms "trailing" behavior? |
EDITED: first version of this post had bad examples. Based on inactivity. Right now, the delay does double-duty.
Let's give those names with examples:
So in the code, it would be just a few minor changes. You'd have the setTimeout to Do you see a bug in that? Ideally, I would then have callback calls coming in at: Let's say another throttled function call comes in right after. You'd have: But that's fine by me. What's most important is twofold: (a) not to take up processing juice during bursts of activity and (b) responsiveness after the burst. What's less important is the resulting spacing of the callback calls. It could be about 250ms with a final call of 50ms. Or it could turn out, as in the extreme scenario above, to be on average 50ms -- that's fine because I know that there were processing cycles available in the gaps between my bursts, as defined by my 50ms finalDelay (a.k.a. burstInterval). In my particular case, the throttled function calls are event handlers on DOM modification events. In other words, not only is there a burst of function calls but these function calls are accompanied by a lot of other activity. So it's not just my callback function that slows down the machine, but other activity associated with the bursts, and that activity has priority. And when that activity is quiet, then my callback function has the next priority and needs to be responsive. |
I put my mods into production: http://huyz.us/google-plus-me/ |
32000 users and no bug yet.... |
Thanks for the updates. This is definitely on my list of things to work on, I just haven't had time yet! |
Heheh yeah I feel you. I have so many feature requests from users and I need to work on a G+ Extension SDK... |
Is this already implemented? |
In my case, the responsiveness of the final call in a throttle is very important.
So I think I need a separate inactivity timeout.
For example, if some event happens during scrolls (say maybe every 5ms), it's nice to space out the actual callback calls to maybe 250ms, but once the scrolling is done, I would like the final callback call to come very quickly, maybe after 50ms of no calls to the throttled function. This is important to make things look right for the user.
I don't want to lower the current delay to 50ms because it slows down my page a lot.
Notice in my example that: 5 ms average interval < 50 ms < 250 ms
If you have no time for this, I could code it with a few tips from you to speed things up.
The text was updated successfully, but these errors were encountered: