LearnNewsExamplesServices
Frontmatter
id9414
titleRefactor `Neo.data.Store` to unify Record Hydration
stateClosed
labels
enhancementairefactoringcore
assigneestobiu
createdAtMar 9, 2026, 3:13 PM
updatedAtMar 9, 2026, 3:18 PM
githubUrlhttps://github.com/neomjs/neo/issues/9414
authortobiu
commentsCount1
parentIssue9404
subIssues[]
subIssuesCompleted0
subIssuesTotal0
blockedBy[]
blocking[]
closedAtMar 9, 2026, 3:18 PM

Refactor Neo.data.Store to unify Record Hydration

Closed v12.1.0 enhancementairefactoringcore
tobiu
tobiu commented on Mar 9, 2026, 3:13 PM

Goal

Extract the duplicate lazy-instantiation ("hydration") logic currently found in Store.get() and Store.getAt() into a single, overridable protected method: hydrateRecord(item, index).

Context

In "Turbo Mode" (autoInitRecords: false), records are stored as raw JSON objects and are only instantiated into Neo.data.Record instances when accessed via get() or getAt(). Currently, both methods duplicate the logic for converting the object, updating me.map, me._items, me.internalIdMap, and the allItems collection.

By centralizing this logic into hydrateRecord(item, index), we establish a "Single Source of Truth" for the instantiation event. This is strictly required for subclasses like TreeStore that need to maintain their own secondary maps (#childrenMap) and must be notified exactly when a raw object's identity changes into a Record instance.

Acceptance Criteria

  • Create hydrateRecord(item, index) in src/data/Store.mjs.
  • Refactor get() and getAt() to simply call return this.hydrateRecord(super.get(key)) (or similar).
  • Ensure existing Store tests continue to pass.
tobiu added the enhancement label on Mar 9, 2026, 3:13 PM
tobiu added the ai label on Mar 9, 2026, 3:13 PM
tobiu added the refactoring label on Mar 9, 2026, 3:13 PM
tobiu added the core label on Mar 9, 2026, 3:13 PM
tobiu added parent issue #9404 on Mar 9, 2026, 3:13 PM
tobiu cross-referenced by #9415 on Mar 9, 2026, 3:13 PM
tobiu referenced in commit 3a143d5 - "refactor: Centralize Record hydration in Store (#9414) on Mar 9, 2026, 3:17 PM
tobiu
tobiu Mar 9, 2026, 3:17 PM

Input from Gemini 3.1 Pro:

✦ Refactored Store.mjs to centralize lazy instantiation into hydrateRecord(item, index). get() and getAt() now delegate to this method.

Pushed to dev.

tobiu assigned to @tobiu on Mar 9, 2026, 3:17 PM
tobiu closed this issue on Mar 9, 2026, 3:18 PM