angular.js icon indicating copy to clipboard operation
angular.js copied to clipboard

"Self only" $scope.$digest() (ie without digesting child scopes)

Open poshest opened this issue 9 years ago • 4 comments

Feature request for 1.x... Something like

$scope.$digest(/*selfOnly*/true)

which, when optional parameter selfOnly is true, only digests the $scope and not its children. My motivation is explained here.

Here's another use case. In fact using Vahan's approach is even better, since it would solve my use case

$scope.$skipChildWatchers = true;
$scope.$digest();
$scope.$skipChildWatchers = false;

....but also allow for his pauseWatchers directive to be easily implemented, which solves https://github.com/angular/angular.js/issues/5301, another issue in which I have great interest.

poshest avatar Oct 21 '16 12:10 poshest

This is indeed similar to #5301. I prefer the idea of detaching/re-attaching a scope (as proposed in #5301), than allowing a scope to control what happens with its child-scopes. Its scope should be in charge of its own fate.

gkalpak avatar Oct 24 '16 09:10 gkalpak

@gkalpak unfortuntately detatching/re-attaching doesn't support my use case, where the current scope could be digested without child scopes being digested.

Also @vahan-hartooni's approach is cleaner code-wise - just stop the recursion when the flag is true. There are a ton of methods/functions with /*recursive*/true parameters. IMHO this would be understood intuitively by most devs.

Contrast detach/re-attach requiring saving of scopes temporarily and making sure they execute after re-attach, which I personally think is more hacky and for that reason less likely to be implemented.

Its scope should be in charge of its own fate.

Yes, but .digest() already digests those child scopes, and therefore already "control[s] what happens with its child-scopes"

poshest avatar Oct 24 '16 11:10 poshest

Issue Status: 1. Open 2. Started 3. Submitted 4. Done


This issue now has a funding of 0.02 BNB (9.75 USD @ $487.37/BNB) attached to it.

gitcoinbot avatar Apr 25 '21 08:04 gitcoinbot

Issue Status: 1. Open 2. Started 3. Submitted 4. Done


The funding of 0.02 BNB (9.75 USD @ $487.37/BNB) attached to this issue has been cancelled by the bounty submitter

gitcoinbot avatar Apr 25 '21 08:04 gitcoinbot