Skip to content

computed efficieny improvement #56269

@bellostom

Description

@bellostom

Which @angular/* package(s) are relevant/related to the feature request?

core

Description

Hi
Right now, computed re evaluates every time any of the underlying signal's properties change, regardless of whether the computed is accessing this property or not, which leads to unnecessary computations and possible re renders.

Coming from MobX, which also has computed but works as described above, makes computed very efficient and performant.
I hope you can consider this improvement, since especially in expensive computations will have a major impact in performance.

Below is an example of the scenario I described
https://stackblitz.com/edit/stackblitz-starters-pjevlf?file=src%2Fapp%2Fservice.ts

Every time the signal's name updates, the computed that calculates the total price re evaluates, although the computed only reads the price property and never accesses the name property.

Regards

Proposed solution

computed should re evaluate only when the signal properties it accesses, change.

Alternatives considered

None

Metadata

Metadata

Labels

area: coreIssues related to the framework runtimecore: reactivityWork related to fine-grained reactivity in the core frameworkcross-cutting: signals

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions