angular/angular.js — pull request #4682 by jolealdoneto (2013-10-28 14:17:52+00:00)
Title: feat($rootScope): add possibility to disable temporarily a scope

I have a use case in mobile applications when I need to keep complex DOM nodes hidden. These should be shown fast (if the user swipes left for example), and because of that I cannot $destroy the scope or remove the DOM completely, or the user experiences a performance impact. So basically they are kept hidden, with watchers and $digests being triggered with no use. They don't need to be updated so frequently, only when they are shown.

So I created this solution, where it creates the possibility to disable the scope temporarily, making the $digest and $broadcast skip it and its children.

I know that the $digest cycle is quite fragile and should be extremely performant, so I sincerely didn't know how to change the behavior without adding the new functions. I've tried using an inline while loop, but the code got really ugly. Maybe a perfomance/logic guru can help making this better.