-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Block Editor: Rename immutableSet to setImmutably #50040
Conversation
Size Change: +2.85 kB (0%) Total Size: 1.37 MB
ℹ️ View Unchanged
|
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.
Code-wise this LGTM 👍
I think we could add a CHANGELOG entry before shipping this though.
* | ||
* @param {Object} object Object to set a value in. | ||
* @param {number|string|Array} path Path in the object to modify. | ||
* @param {*} value New value to set. | ||
* @return {Object} Cloned object with the new value set. | ||
*/ | ||
export function immutableSet( object, path, value ) { | ||
export function setImmutably( object, path, value ) { |
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 think this rename could use a CHANGELOG entry. We already have an existing changelog entry for immutableSet
so by keeping a changelog entry for renaming it, one could trace what happened to it.
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.
Done in 8bf123e
* | ||
* @param {Object} object Object to set a value in. | ||
* @param {number|string|Array} path Path in the object to modify. | ||
* @param {*} value New value to set. | ||
* @return {Object} Cloned object with the new value set. | ||
*/ | ||
export function immutableSet( object, path, value ) { | ||
export function setImmutably( object, path, value ) { |
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 just wanted to note that from my perspective, immutableSet
wasn't a bad name, recognizable since it exists in other languages (Java AFAIK) and also there's Immutable.js and an immutable-set
package. I've never seen setImmutably
in code, rather I've seen setImmutable
. I don't have very strong feelings about it though.
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.
If I'm the only one having problems with the name, then I'm happy to close this PR! I opened it based on the two 👍 reactions to the original comment. Or, at the very least, revert the name change and just rephrase the docblock. wdyt, @tyxla?
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.
To be honest, I did have a small issue with the name, at first I also didn't know what the function did until I looked at the tests. It felt more as an object creator. But I generally don't feel strongly about the naming things.
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 agree naming is hard. I also agree with y'all that immutableSet
is far from ideal. I'm just not convinced that setImmutably
is much better. At the same time, I can't think of a better name that isn't longer. Just like Riad, I have no strong feelings either. That's precisely why I approved the PR and am happy to go with what you suggested 😉
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.
Alright, kids! Then I guess I'll merge once it's green. :)
Also tweaked the documentation of the function.
Addresses #49365 (comment)