-
Notifications
You must be signed in to change notification settings - Fork 396
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
Add compare key to computed using accessor syntax #3245
Comments
Computeds always fire whenever its dependencies change (in this case, In your case, however, your computed will always trigger dependents because it always returns a new object by way of an |
Exactly my point. I'd like to see a way to customize the equality check so I don't unnecessarily update the downstream where
My example was intentionally an oversimplification. I was more giving the example to show the compare syntax. |
There was an issue a while back to make ractive more immutable-friendly by allowing a I will say that outside of strict (usually I'll take a poke at it when I get a few spare cycles if no one else beats me to it. |
@briancray : as a workaround, you could do the compare yourself in the |
Currently you can use computeds with get() and set() keys as the syntax. I'd love to also see a compare() key. The compare key allows you to define a custom comparator for new and old values to see whether downstream dependencies and observers should fire.
I could be wrong, but right now all non-literal computeds seem to always fire observers when their upstream values change. This change would allow me to stop non-changes to objects from trickling downstream unnecessarily.
For example:
This would use
JSON.stringify(val) === JSON.stringify(oldVal)
instead ofval === oldVal
The text was updated successfully, but these errors were encountered: