OnPush constant
int
const OnPush
An optimized form of change detection, skipping some checks for changes.
Unlike Default, OnPush waits for the following signals to check a component:
- An
@Input()
on the component being changed. - An
@Output()
or event listener (i.e.(click)="..."
) being executed in the template of the component or a descendant. - A call to
<ChangeDetectorRef>.markForCheck()
in the component or a descendant.
Otherwise, change detection is skipped for this component and its descendants. An OnPush configured component as a result can afford to be a bit less defensive about caching the result of bindings, for example.
WARNING: It is currently undefined behavior to have a Default configured component as a child (or directive) of a component that is using OnPush. We hope to introduce more guidance here in the future.
Implementation
static const OnPush = 5;