Open YonatanKra opened 8 years ago
If all the unit tests work and all of the tutorials work, then I see nothing but positives for this change. You want to submit a PR?
Made a PR for this: https://github.com/angular-ui/ui-grid/pull/5829
Ping @swalters
@YonatanKra https://github.com/angular-ui/ui-grid/pull/5829 just got merged, if you are happy with the changes maybe this can be closed.
There are way too many digest cycles for the grid load/rendering. I've managed to reduce the load by setting some of the
$timeout
s to$timeout(method, 0, false)
. I've managed to reduce the number by 2/3 this way, with no seeming side effects (and my app now loads much faster - I have around 9-10 grids on one page, that can open side menus with more, so this is critical...).I've created a plnkr that shows that every load, you get roughly 35 digest cycles - with no extra feature involved: http://plnkr.co/edit/uOYKeJvANJu1b9zk8Ac1?p=catalogue (it also shows that the grid increases the number of digests each time it reloads which might indicate a memory leak, but then again, it might be just the demo app).
For instnace: https://github.com/angular-ui/ui-grid/blob/1dc9931f88d7b2183ae25d16df0ab6192cba997d/src/js/core/directives/ui-grid.js#L244 init is being called iniside a
$timeout
. It then callsgrid.refreshCanvas
which in turn does another$timeout
(https://github.com/angular-ui/ui-grid/blob/a1e6a04ced73dfc4ef83000f5e44fc6aeec6d7b3/src/js/core/factories/Grid.js#L2121), hence calleing twich to a digest cycle...As I said, I've managed to reduce this number of cycles with the method above. Is there a special reason why there are so many
$timeout
s inside the core code?