use deep quality comparison for derived updates - #141
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
_.isEqualmethod. Helps prevent triggering unnecessary change events when a derived property is not a primitive data type.