Skip to content

feat(core): Reduce digest triggers when using $timeout #5829

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

Merged
merged 1 commit into from
Dec 5, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/js/core/directives/ui-grid.js
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ function uiGridDirective($compile, $templateCache, $timeout, $window, gridUtil,
sizeChecks++;
}
else {
$timeout(init);
$timeout(init, 0, false);
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/js/core/factories/Grid.js
Original file line number Diff line number Diff line change
Expand Up @@ -2244,13 +2244,13 @@ angular.module('ui.grid')
}

p.resolve();
});
}, 0, false);
}
else {
// Timeout still needs to be here to trigger digest after styles have been rebuilt
$timeout(function() {
p.resolve();
});
}, 0, false);
}

return p.promise;
Expand Down
8 changes: 4 additions & 4 deletions src/js/core/services/ui-grid-util.js
Original file line number Diff line number Diff line change
Expand Up @@ -831,7 +831,7 @@ module.service('gridUtil', ['$log', '$window', '$document', '$http', '$templateC
} else {
s.logWarn('[focus.byId] Element id ' + elementID + ' was not found.');
}
});
}, 0, false);
this.queue.push(promise);
return promise;
},
Expand All @@ -856,7 +856,7 @@ module.service('gridUtil', ['$log', '$window', '$document', '$http', '$templateC
if (element){
element[0].focus();
}
});
}, 0, false);
this.queue.push(promise);
return promise;
},
Expand Down Expand Up @@ -886,8 +886,8 @@ module.service('gridUtil', ['$log', '$window', '$document', '$http', '$templateC
};
this._purgeQueue();
if (aSync){ //Do this asynchronysly
var promise = $timeout(focusBySelector);
this.queue.push($timeout(focusBySelector));
var promise = $timeout(focusBySelector, 0, false);
this.queue.push($timeout(focusBySelector), 0, false);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@csvan there is a mistake here, should be:

this.queue.push($timeout(focusBySelector, 0, false));

right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes that's a mistake

return promise;
} else {
return focusBySelector();
Expand Down