Reputation: 15471
If I were to create a $watch
expression like:
$scope.$watch(function(){
return(MyDataStore.someInstanceVariable);}
, function(newVal, oldVal){
$scope.scopeVariable = newVal;}
, true)
How often would this function execute? How often would it poll the data store? Just how (in)efficient is this approach?
Upvotes: 0
Views: 641
Reputation: 483
From the angularjs docs:
The watchExpression is called on every call to $digest() and should return the value which will be watched. (Since $digest() reruns when it detects changes the watchExpression can execute multiple times per $digest() and should be idempotent.)
See the docs at: Angularjs Watch
Upvotes: 1