feat(core): Mark components for check if they read a signal by atscott · Pull Request #49153 · angular/angular
atscott
marked this pull request as ready for review
alxhub previously requested changes Feb 23, 2023
atscott
added
action: merge
and removed action: review
The PR is still awaiting reviews from at least one requested reviewerlabels
Mar 16, 2023This commit updates the `LView` in Angular to be a `Consumer` of signals. If a signal is read when executing a template, it marks the view dirty. In addition, if a signal is read when executing host bindings, it also marks views dirty. One interesting thing about signal reads in host bindings is that they perform a bit better than what we can do with today's APIs. In order to re-execute host bindings for an `OnPush` component that might have changed, you would probably inject `ChangeDetectorRef` and call `markForCheck`. This will mark the _current component_ and parents dirty. However, host bindings are executed as part of refreshing the _parent_ so there is really no need to re-execute the current component if the only thing that changed is the host bindings. When a signal is read in host bindings, it marks the parent dirty and not the component that defined the host binding. Additionally, this commit avoids allocating a full consumer for each `LView` by re-using a consumer until template execution results in a signal read. At this point, we assign that consumer to the `LView` and create a new consumer to "tentatively" use for the future `LView` template executions. Co-authored-by: Dylan Hunn <github@dylanhunn.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters