-
Notifications
You must be signed in to change notification settings - Fork 75
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
use deep quality comparison for derived updates #141
base: master
Are you sure you want to change the base?
Conversation
@CristiScheye thanks for the feedback! I believe this should utilize This will reduce whole code to: var isObjectEqual = require('amp-is-object-equal');
if (!isObjectEqual(self._cache[name], newVal) || !def.cache) { ... } |
@kamilogorek thanks for the pointer, and sorry for the delayed response! |
Looks good to me @CristiScheye. Could you please rebase, so it can get merged? |
e44a79b
to
eb47ccb
Compare
👍 |
Looks good, thanks! |
My only concern about this is a performance hit on derived property changes. Thoughts @HenrikJoreteg ? |
Hard to say what type of performance hit it would actually have, but shouldn't be significant for simple values, it should only be a hit if you're comparing more complex objects, which is probably still better than falsely triggering changes that turn into DOM updates. This seems like a reasonable change to me. +1 |
Oh, and just to be annoying, now that we're not using amp anymore, amp-is-object-equal will need to be |
Easy fix, though. But yeah, we should swap that out. |
Saw this so I decided to update #116. it allows a type to be specified for derived properties and if it exists to use the dataType compare method which defaults to |
Instead of using strict comparison on derived property changes, uses the
_.isEqual
method. Helps prevent triggering unnecessary change events when a derived property is not a primitive data type.