Angular, specifically through zone.js, applies patches to functions like setTimeout()
, event listeners, and more. This is done to trigger the Change Detector when the respective callbacks are executed. However, Angular faces the challenge of not knowing which objects have been updated and which remain unchanged. As a result, Angular has to check every property used in the template to determine if it has changed or not, making this approach less efficient.
So, my question is: Why doesn't Angular utilize Proxy objects for this purpose? By using Proxy objects, Angular would be able to precisely identify what has been changed without needing to compare the entire state tree. Is there a specific reason why Angular developers opted against incorporating Proxy objects (as seen in Vue)?
On a side note, one key advantage of using a Proxy object could be the ability to call functions within templates without triggering additional or unnecessary Change Detection cycles:
<div *ngFor="let item of myFunction()">...</div>