-
Notifications
You must be signed in to change notification settings - Fork 27.4k
Use exposed equals inside watch and equals #5913
Conversation
I'm sorry, but I wasn't able to verify your Contributor License Agreement (CLA) signature. CLA signature is required for any code contributions to AngularJS. Please sign our CLA and ensure that the CLA signature email address and the email address in this PR's commits match. If you signed the CLA as a corporation, please let us know the company's name. Thanks a bunch! PS: If you signed the CLA in the past then most likely the email addresses don't match. Please sign the CLA again or update the email address in the commit of this PR. |
@@ -820,7 +820,7 @@ function equals(o1, o2) { | |||
if (!isArray(o2)) return false; | |||
if ((length = o1.length) == o2.length) { | |||
for(key=0; key<length; key++) { | |||
if (!equals(o1[key], o2[key])) return false; | |||
if (!angular.equals(o1[key], o2[key])) return false; |
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.
I don't understand? what is the motivation for this? so that you can customize the equals function?
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.
exactly! when i know that in my SPA there are a lot of comparisons of a specific type, i can create a better comparison for that type (that depends only on the minimum number of properties that object needs. and then use the proxy pattern to replace the equals so that it will perform better for my SPA
this doesn't look right. we rely on equals implementation heavily at many places throughout the framework, we can't let you monkey patch it and hope for the best. it would be better if you described your use-cases in a bug/feature issue and then we can decide how to deal with it. |
Of course angular depends heavily on equals - this is exactly why it is important that i will be able to enhance equals to fit better for my own SPA Assume that there are a lot of watchs on instances of MyClass the proxy pattern for doing that will be something like this:
|
👍
|
Setting a comparable interface works too. With less danger for framework
|
This will allow using the proxy pattern for providing better equals implementation for specific cases
very good when you use an existing widget that performs watch on some property that you can provide a faster way to equal check it but you want to do it without changing the widget code