LearnNewsExamplesServices
Frontmatter
titlefeat: implement updateKey() method for Neo.collection.Base #9196
authorjhawpetoss6-collab
stateMerged
createdAtMar 24, 2026, 2:27 AM
updatedAtMar 24, 2026, 9:53 AM
closedAtMar 24, 2026, 9:53 AM
mergedAtMar 24, 2026, 9:53 AM
branchesdevstrike/collection-update-key
urlhttps://github.com/neomjs/neo/pull/9536
Merged
jhawpetoss6-collab
jhawpetoss6-collab commented on Mar 24, 2026, 2:27 AM

This PR implements the updateKey(item, newKey) method for Neo.collection.Base, addressing the need for safe key updates within collections (#9196).

Changes:

  • Added updateKey() to the Collection base class.
  • Ensures the internal map stays in sync with the item property.
  • Preserves the items index in the array (Zero Array Mutation).
  • Fires an updateKey event for observability.

/claim #9196

tobiu
tobiu commented on Mar 24, 2026, 9:52 AM

Hello and welcome to the Neo.mjs project! Thank you for picking up this ticket and for your contribution.

This is a great implementation of the baseline requirement. Providing a clean way to update keys without triggering expensive array re-sorts via remove/add cycles is a very welcome addition to the Collection core.

Since this is a brand new method and isn't actively wired up to the rest of the framework yet, it is low risk, and we are happy to accept and merge this PR as your first official contribution!

To make this feature fully robust across the entire framework architecture, we will need to handle a couple of edge cases (specifically, filtered collections and the newly introduced TreeStore). We have created two follow-up tickets to track these integrations:

  1. #9538: Enhance Collection.updateKey() to support filtered collections (allItems map).
  2. #9539: Add TreeStore override for updateKey() to ensure private structural maps stay in sync.

We will merge this PR now. If you are interested in continuing to work on this feature, you are more than welcome to claim either of those follow-up tickets—just drop a comment on them!

Thank you again for jumping in, and we look forward to reviewing your next PR.