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

Derived properties are calculated unnecessarily often #238

Open
janpaul123 opened this issue Apr 7, 2016 · 1 comment
Open

Derived properties are calculated unnecessarily often #238

janpaul123 opened this issue Apr 7, 2016 · 1 comment

Comments

@janpaul123
Copy link
Contributor

Say you have derived properties like this:

derived: {
  A: { deps: ['X'], fn:  },
  B: { deps: ['X'], fn:  },
  C: { deps: ['X'], fn:  },
  Z: { deps: ['A', 'B', 'C'], fn:  },
}

Currently, if you change X, the function for Z will trigger 3 times, like this (every letter is a function executing): A Z B Z C Z, while it's clearly sufficient to do A B C Z (or, perhaps, to not do anything until later, as suggested in #233).

There are a few workarounds for this (denormalising derived properties, using silent: true + custom events, …?) and I might post them here later, but I haven't quite figured out the pros/cons of them.

@cdaringe
Copy link
Member

cdaringe commented Apr 7, 2016

interesting. makes sense. it's as though though a derived recompute needs memoization with cache size === 1

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

2 participants