-
Notifications
You must be signed in to change notification settings - Fork 31
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
Allow value equality checker to be overridden #21
base: master
Are you sure you want to change the base?
Conversation
@@ -114,5 +114,9 @@ export default Ember.Mixin.create({ | |||
if (empty(this.buffer)) { | |||
this.set('hasBufferedChanges', false); | |||
} | |||
}, | |||
|
|||
_compareValues(a, b) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since you're intending the consumer to override this in some situations, why did you go with the _
naming convention here?
This seems like a totally sane use case @HeroicEric , especially because this implementation strategy won't change the behavior for folks if they don't want / care to know about this. If you'd like to rebase this old branch and write some tests, I think it would be a great addition. |
c1e71b8
to
d47b17f
Compare
Sorry for letting this linger for so long but I need it again 😄 I updated this with some docs and renamed the function. |
d47b17f
to
77ca797
Compare
No problem - this looks great to me and it backwards compatible. cc @lukemelia do you want to have a look and sign off on this? @HeroicEric if I don't hear from Luke in a few days, I can merge. |
@blimmer I just remembered why the function was initially underscored. I thought it might be better in terms of avoiding potentially causing issues with the underlying content having a key with the same name. I think it's probably uncommon to have an |
That's a good point, though underscored methods usually indicate don't use this to me. You could use something less likely to be overridden like 'bufferedProxyIsEqual' or the like. |
It would be nice if there was a way to override how values are compared inside of
setUknownProperty
without having to override the whole function.For example, we're working on an app where we're buffering changes made to an array of POJOs and
===
doesn't detect equality there like we want it to so we're using_.isEqual
from lodash.This also makes it easy to override how values for a specific key are compared.
I'm not a fan of the function name I used here but I wanted to see if you're open to this possibility before spending any more time on it.
Another option could be using
Ember.isEqual
, since you can defineisEqual
for whatever you want, but this would require converting to anEmber.Object
, making it a little less flexible.