I have a complex task running in an Angular controller with watchers that may be triggered during the execution of the code. In order to improve performance, I don't want these watchers to interfere. Is there a way to prevent Angular from triggering certain watchers while my code is running? Is this handled internally by Angular or can it be achieved using $q or another method?
For example:
$scope.variableThatKeepsChanging = {};
function someVeryLongFunction(){
var someVar = variableThatKeepsChanging;
(...);
}
$scope.clickedFn = function () {
//Call the very long function here
someVeryLongFunction();
//Only then should we invoke the $apply() function in Angular
}
//Note: The watcher should detect changes not made by someVeryLongFunction()
$scope.$watch('variableThatKeepsChanging', function () {doSomething()});
Thank you.