-
Notifications
You must be signed in to change notification settings - Fork 6.8k
refactor(mdc-prototypes): do not mark components dirty in input setters #16129
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor(mdc-prototypes): do not mark components dirty in input setters #16129
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, but there's a lint failure.
src/material-experimental/mdc-slide-toggle/slide-toggle.spec.ts
Outdated
Show resolved
Hide resolved
In order to make our component inputs which use boolean coercion more consistent with other inputs which aren't declared through setters, we should no longer call `markForCheck` within input setters as Angular automatically runs change detection if input values are updated. This breaks the programmatic usage of these inputs as Angular in that case won't be able to run change detection (since it can't detect that the value of the input changes).. though this is a more general problem with the `OnPush` strategy as we can't have consistent behavior for programmatic input updates without switching *every* input to a setter. Instead, in order to still support programmatic input updates, we should expose a method that allows developers to mark the MDC components as dirty. This is necessary so that developers which _really_ need to update programmatically (e.g. through `ViewChild`) can still update the componet to reflect the changes. The benefit is that we don't need to convert every input to a setter w/ markForCheck in order to make the OnPush inputs behavior consistent. Related to COMP-170
202a9e3
to
1d4c09a
Compare
…t setters Proposal to just not support programmatic input updates
f90baaa
to
c142748
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
…rs (angular#16129) In order to make our component inputs which use boolean coercion more consistent with other inputs which aren't declared through setters, we should no longer call `markForCheck` within input setters as Angular automatically runs change detection if input values are updated. This breaks the programmatic usage of these inputs as Angular in that case won't be able to run change detection (since it can't detect that the value of the input changes).. though this is a more general problem with the `OnPush` strategy as we can't have consistent behavior for programmatic input updates without switching *every* input to a setter. Instead, in order to still support programmatic input updates, we should expose a method that allows developers to mark the MDC components as dirty. This is necessary so that developers which _really_ need to update programmatically (e.g. through `ViewChild`) can still update the componet to reflect the changes. The benefit is that we don't need to convert every input to a setter w/ markForCheck in order to make the OnPush inputs behavior consistent. Related to COMP-170
…rs (#16129) In order to make our component inputs which use boolean coercion more consistent with other inputs which aren't declared through setters, we should no longer call `markForCheck` within input setters as Angular automatically runs change detection if input values are updated. This breaks the programmatic usage of these inputs as Angular in that case won't be able to run change detection (since it can't detect that the value of the input changes).. though this is a more general problem with the `OnPush` strategy as we can't have consistent behavior for programmatic input updates without switching *every* input to a setter. Instead, in order to still support programmatic input updates, we should expose a method that allows developers to mark the MDC components as dirty. This is necessary so that developers which _really_ need to update programmatically (e.g. through `ViewChild`) can still update the componet to reflect the changes. The benefit is that we don't need to convert every input to a setter w/ markForCheck in order to make the OnPush inputs behavior consistent. Related to COMP-170
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
In order to make our component inputs which use boolean coercion more
consistent with other inputs which aren't declared through setters, we should
no longer call
markForCheck
within input setters as Angular automaticallyruns change detection if input values are updated.
This breaks the programmatic usage of these inputs as Angular in that case
won't be able to run change detection (since it can't detect that the value
of the input changes).. though this is a more general problem with the
OnPush
strategy as we can't have consistent behavior for programmaticinput updates without switching every input to a setter.
Instead, in order to still support programmatic input updates, we
could expose a method that allows developers to mark the MDC
components as dirty. This is necessary so that developers which
really need to update programmatically (e.g. through
ViewChild
)can still update the componet to reflect the changes. The benefit is
that we don't need to convert every input to a setter w/ markForCheck
in order to make the OnPush inputs behavior consistent.
Related to COMP-170
Note: Removal of
markForCheck
as discussed in the last meeting and an additional proposal of adding amarkForCheck
method to components in order to still support programmatic input updates.