What the difference between markDirty() and markForCheck()

Viewed 865

With new Ivy compilation and rendering pipeline we also have a few new functions for working with change detector.

I'm interested in markDirty().

As far as I understand this function provides an ability to schedule change detection firing for a component in some future. Yes, I understand that it's currently unstable functionality, but it's already provided in angular.core.

So my question is: What is the difference between markDirty() and ChangeDetectorRef.markForCheck()? And what benefits are provided by this function?

1 Answers

markDirty and markForCheck are used for OnPush [ChangeDetectionStrategy]: https://angular.io/api/core/ChangeDetectorRef

This is a special mode that only marks components dirty in two cases:

  1. There has been a change to an @Input property
  2. markDirty() has been called manually by the user.
Related