Skip to content
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

computed properties are re-evaluating more often than expected #8540

Closed
indirectlylit opened this issue Jul 22, 2018 · 4 comments
Closed

computed properties are re-evaluating more often than expected #8540

indirectlylit opened this issue Jul 22, 2018 · 4 comments

Comments

@indirectlylit
Copy link

indirectlylit commented Jul 22, 2018

Version

2.5.16

Reproduction link

https://jsfiddle.net/eywraw8t/193744/

Steps to reproduce

  • Create some data A and computed props B and C
  • Let C depend on B, and B depend on A. Set it up so the value of B should change less often than A
  • Then modify A

What is expected?

The value of C should only be re-computed when the value of B changes, independent of how often A is changing.

What is actually happening?

The value of C is re-computed whenever A changes. This results in many extra re-computations.


The docs say:

A computed property will only re-evaluate when some of its dependencies have changed.

In this case, I thought there was a bug in my code because certain threshold-based computed properties were triggering re-computes far more often than expected, and some of these re-computes were fairly expensive.

Perhaps is expected behavior? However it was surprising to me, and negates a lot of the potential for cache-based optimization when leveraging computed props.

Compare to this implementation that uses watchers and extra data, but works as expected:

https://jsfiddle.net/eywraw8t/193746/

Here, C is only recomputed when B changes - not whenever A changes.

@sqal
Copy link
Contributor

sqal commented Jul 22, 2018

seems to be fixed in 2.5.17-beta.0

@indirectlylit
Copy link
Author

seems to be fixed in 2.5.17-beta.0

note - reverted and not released due to regressions

@zfeher
Copy link

zfeher commented Oct 15, 2018

We also ran into a similar issue today.

When can we expect the fix to be released for this?

We can't use the v2.5.17-beta.0 because some things broke when we tried it so we reverted back to 2.5.16. This problem can cause some headaches, would be nice to have the fix released.

@Justineo
Copy link
Member

Justineo commented Nov 5, 2018

Duplicate of #7767

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants