Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.
Sign upPager $watchers will not fire if sum of totalItems and page size stays the same #2096
Conversation
…tegers to avoid possible addition mistakes of watching 'a + b' when the sum stays the same.
|
@c0bra, isn't a solution to a problem you mentioned ? Is this commit good to be merged or should it be improved ? |
|
@igormalyk I think the right thing to do would be to have the $watch be on a function that returns an object containing the current page and page-size options, like so: $scope.$watch(function() {
return {
a: $scope.grid.options.pagingCurrentPage,
b: $scope.grid.options.pagingPageSize
};
}, function () { ... })This jsperf test shows that there's an 80% performance hit by doing explicit string conversions: http://jsperf.com/ui-grid-paging-watch-method |
|
Didn't think about performance at that time. You are right, @c0bra solution with objects is much better. |
|
@igormalyk I wasn't intending for you to close this. Switching it over to using an function in the $watch should be pretty straightforward. I still think we need this PR! |
igormalyk commentedNov 14, 2014
As mentioned by @c0bra at brianchance@45e1b5c#commitcomment-8565148
if decrement and increment of the totalItems and page size don't change the overall sum within one digest cycle then watchers will not fire. Changing the $watch expression to a function which compares string values fixes this.