-
Notifications
You must be signed in to change notification settings - Fork 461
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
Perhaps use throttled $watch instead of addPollFn? #2
Comments
Something like: $rootScope.$watch(onDigest);
var compareTimeout;
function onDigest() {
if (!compareTimeout) {
compareTimeout = setTimeout(compare, 100);
}
}
function compare() {
compareTimeout = null;
//do compare and set to localStorage if dirty
} |
Sounds nice, lazy binding / dirty check debouncing is actually something on the todo list. Care to send in a PR? |
@ajoslin Any progress on this? |
No, forgot to reply sorry :-) Don't have time atm. On Tue, Aug 13, 2013 at 3:06 AM, Gias Kay Lee notifications@github.comwrote:
|
The compare should never be huge. |
For this reason I would actually advocate for a rootscope watcher. The comparisons should be lightning fast. The debounce itself is a comparison ("is a timer already set?"). I think you're both overthinking this. The check for whether an update is needed ( Maybe it makes sense to add the |
Hi there, Cheers, |
I see why you used addPollFn instead of $rootScope.$watch; for many rapid actions you don't want to do a potentially huge compare every $digest.
But if I use this, I also don't want to have a potentially huge compare every 100ms, especially on things like android 2.x browser.
...so what if on every $digest, if there's no timeout, you set a new timeout to compare in 100ms?
The text was updated successfully, but these errors were encountered: