Reputation: 129
In https://hackernoon.com/everything-you-need-to-know-about-change-detection-in-angular-8006c51d206f
He say that angular has 14 operations but which exact moment it's checked if the component is ChecksEnabled == false (OnPush) and especially if it's OnPush at what time it checks some @Input properties has changed to run the process inside it? And continue with the check in the DOM and invoke the required life cycles ?
And if the value is a new reference, it will run the check only on the properties of that value of @Input or at all in the binding? Agree with me that it would be much more performatic if he just checks the value bindings of that element?
Upvotes: 1
Views: 330
Reputation: 105439
At which exact moment it's checked if the component is ChecksEnabled == false (OnPush)
It's happening when Angular runs checks for child views:
Here is the relevant code:
function callViewAction(view: ViewData, action: ViewAction) {
const viewState = view.state;
switch (action) {
...
case ViewAction.CheckAndUpdate:
if ((viewState & ViewState.Destroyed) === 0) {
if ((viewState & ViewState.CatDetectChanges) === ViewState.CatDetectChanges) {
checkAndUpdateView(view);
} else if (viewState & ViewState.CheckProjectedViews) {
execProjectedViewsAction(view, ViewAction.CheckAndUpdateProjectedViews);
}
}
break;
At what time it checks some @Input properties has changed to run the process inside it
This is performed for this step:
To learn more about it read The mechanics of property bindings update in Angular
And continue with the check in the DOM and invoke the required life cycles ?
This will be done on:
To learn more read The mechanics of DOM updates in Angular
Upvotes: 3