-
-
Notifications
You must be signed in to change notification settings - Fork 6
Equals not used when values updated #150
Comments
I very quickly skimmed through the original thread and I believe this is at most a feature request and is mostly just intended behavior. Keeping open for now. |
Coming from C++, Java and C# I still think this is not very intuitive and unexpected. |
I read through the issue again a little more carefully. I believe your argument/suggestion is that the The first suggestion would be a breaking change which makes it less likely to happen. We would have to be convinced that the improvement is worth more than the cost of the breaking change. The second suggestion could be released in a minor version, so it has more potential. C++, Java, and C# are all (at least in some sense) object-oriented programming languages and are all similar to each other. JavaScript is not intended to be object-oriented. There are going to be things that are not intuitive and unexpected when switching from an object-oriented programming language to JavaScript. Not every object having an |
I understand your first argument. But I don't agree with the second argument. For me the point is not that C# behaves differently than javascript. The point is consistency. C# is very consistent when you use equality. You can either use the default equals implementation or implement your own and it is respected by all collections. Immutable-js also has its own definition of equality or value equality to be more precise and and it is not used consistently and this hurts performance, because it is more likely that 2 collections with the different references are actually equal and therefore it is causing unnecessary updates in the UI layer. |
I was just disagreeing with your point that "this is not very intuitive and unexpected." If immutable were implemented in C++, Java, and C#, I would agree that it would unexpected since each of those languages has a way of defining equality which is expected to be respected by code that uses equality. I was just trying to point out the fact that JavaScript does not have that same ubiquitous definition of equality that can be override by any data type (i.e., an immutable uses two definitions of equality and I think that it fairly consistently uses the I'm not saying your proposal is not a good idea (and it might help performance). I'm just saying that it's working as intended (i.e., this isn't a bug in immutable) and I don't think it needs to be a priority to change it. |
But how are the
I cannot find the implementation for that. deepEquals uses the But I totally understand your point and priorities. |
From @SebastianStehle on Sat, 07 Sep 2019 20:12:55 GMT
Hi, I was playing around with immutable.js and I like the equals checks.
What I do not understand is that these checks are not used for updates, e.g. I was playing around with Record and Map:
https://codesandbox.io/s/hidden-sound-h5o2t
Copied from original issue: immutable-js#1732
The text was updated successfully, but these errors were encountered: