Skip to content

Commit 7e25a9b

Browse files
committed
feat(core): Reduce digest triggers when using $timeout
Angular's $timeout takes a boolean 3rd parameter which causes the wrapped function to not run inside $apply. Since $timeout is used extensively in scope, this parameter has been passed where possible in order to improve performance, since the grid otherwise triggers a large number of digests while functioning normally. See issue: #5007
1 parent b35fca4 commit 7e25a9b

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

src/js/core/directives/ui-grid.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ function uiGridDirective($compile, $templateCache, $timeout, $window, gridUtil,
241241
sizeChecks++;
242242
}
243243
else {
244-
$timeout(init);
244+
$timeout(init, 0, false);
245245
}
246246
}
247247

src/js/core/factories/Grid.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -2244,13 +2244,13 @@ angular.module('ui.grid')
22442244
}
22452245

22462246
p.resolve();
2247-
});
2247+
}, 0, false);
22482248
}
22492249
else {
22502250
// Timeout still needs to be here to trigger digest after styles have been rebuilt
22512251
$timeout(function() {
22522252
p.resolve();
2253-
});
2253+
}, 0, false);
22542254
}
22552255

22562256
return p.promise;

src/js/core/services/ui-grid-util.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -831,7 +831,7 @@ module.service('gridUtil', ['$log', '$window', '$document', '$http', '$templateC
831831
} else {
832832
s.logWarn('[focus.byId] Element id ' + elementID + ' was not found.');
833833
}
834-
});
834+
}, 0, false);
835835
this.queue.push(promise);
836836
return promise;
837837
},
@@ -856,7 +856,7 @@ module.service('gridUtil', ['$log', '$window', '$document', '$http', '$templateC
856856
if (element){
857857
element[0].focus();
858858
}
859-
});
859+
}, 0, false);
860860
this.queue.push(promise);
861861
return promise;
862862
},
@@ -886,8 +886,8 @@ module.service('gridUtil', ['$log', '$window', '$document', '$http', '$templateC
886886
};
887887
this._purgeQueue();
888888
if (aSync){ //Do this asynchronysly
889-
var promise = $timeout(focusBySelector);
890-
this.queue.push($timeout(focusBySelector));
889+
var promise = $timeout(focusBySelector, 0, false);
890+
this.queue.push($timeout(focusBySelector), 0, false);
891891
return promise;
892892
} else {
893893
return focusBySelector();

0 commit comments

Comments
 (0)