Skip to content

fix(core): fix change tracking for Resource#hasValue#62595

Closed
lizclipse wants to merge 1 commit intoangular:mainfrom
lizclipse:fix-resource-hasvalue-computed
Closed

fix(core): fix change tracking for Resource#hasValue#62595
lizclipse wants to merge 1 commit intoangular:mainfrom
lizclipse:fix-resource-hasvalue-computed

Conversation

@lizclipse
Copy link
Contributor

When using hasValue() I would expect it to behave like any other reactive value such that changes to the internal value() that do not cause hasValue() to return anything different do not trigger change detection, but this was not the case. This change wraps the value checking in a computed such that it behaves as expected again while still preserving the type narrowing.

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • angular.dev application / infrastructure changes
  • Other... Please describe:

What is the current behavior?

Each time a resource's value changes, even if it changes from e.g. a defined to a defined value, consumers of hasValue() will re-run.

Issue Number: N/A

What is the new behavior?

Consumers of hasValue() will re-run only if it has actually changed, preventing unnecessary change detection.

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

When using `hasValue()` I would expect it to behave like any other
reactive value such that changes to the internal `value()` that do not
cause `hasValue()` to return anything different do not trigger change
detection, but this was not the case. This change wraps the value
checking in a `computed` such that it behaves as expected again while
still preserving the type narrowing.
@pullapprove pullapprove bot requested a review from mmalerba July 11, 2025 17:49
@angular-robot angular-robot bot added the area: core Issues related to the framework runtime label Jul 11, 2025
@ngbot ngbot bot added this to the Backlog milestone Jul 11, 2025
@mmalerba mmalerba added action: merge The PR is ready for merge by the caretaker target: patch This PR is targeted for the next patch release labels Jul 16, 2025
@kirjs
Copy link
Contributor

kirjs commented Jul 18, 2025

This PR was merged into the repository by commit b8e415a.

The changes were merged into the following branches: main, 20.1.x

@kirjs kirjs closed this in b8e415a Jul 18, 2025
kirjs pushed a commit that referenced this pull request Jul 18, 2025
When using `hasValue()` I would expect it to behave like any other
reactive value such that changes to the internal `value()` that do not
cause `hasValue()` to return anything different do not trigger change
detection, but this was not the case. This change wraps the value
checking in a `computed` such that it behaves as expected again while
still preserving the type narrowing.

PR Close #62595
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Aug 18, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

action: merge The PR is ready for merge by the caretaker area: core Issues related to the framework runtime target: patch This PR is targeted for the next patch release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants