Skip to content

Commit 0d3ccb8

Browse files
committed
Merge branch 'Robinson7D-improve_watcher_perf' into dev
Conflicts: dist/angular-datatables.min.js
2 parents 08050b0 + 2cfd582 commit 0d3ccb8

File tree

3 files changed

+26
-9
lines changed

3 files changed

+26
-9
lines changed

dist/angular-datatables.js

+12-2
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,7 @@
378378
compile: function (tElm) {
379379
var _staticHTML = tElm[0].innerHTML;
380380
return function postLink($scope, $elem, iAttrs, ctrl) {
381-
$scope.$watch('[dtOptions, dtColumns, dtColumnDefs]', function (newVal, oldVal) {
381+
function handleChanges(newVal, oldVal) {
382382
if (newVal !== oldVal) {
383383
var newDTOptions = newVal[0], oldDTOptions = oldVal[0];
384384
// Do not rerender if we want to reload. There are already
@@ -391,7 +391,17 @@
391391
newDTOptions.reload = false;
392392
}
393393
}
394-
}, true);
394+
}
395+
// Options can hold heavy data, and other deep/large objects.
396+
// watchcollection can improve this by only watching shallowly
397+
var watchFunction = iAttrs.disableDeepWatchers ? '$watchCollection' : '$watch';
398+
angular.forEach([
399+
'dtColumns',
400+
'dtColumnDefs',
401+
'dtOptions'
402+
], function (tableDefField) {
403+
$scope[watchFunction].call($scope, tableDefField, handleChanges, true);
404+
});
395405
ctrl.showLoading($elem);
396406
ctrl.render($elem, ctrl.buildOptionsPromise(), _staticHTML);
397407
};

0 commit comments

Comments
 (0)