Frontmatter
| id | 8097 |
| title | Introduce autoInitRecords config for Neo.data.Store |
| state | Closed |
| labels | enhancementdeveloper-experienceai |
| assignees | tobiu |
| createdAt | Dec 12, 2025, 1:57 PM |
| updatedAt | Dec 12, 2025, 2:08 PM |
| githubUrl | https://github.com/neomjs/neo/issues/8097 |
| author | tobiu |
| commentsCount | 1 |
| parentIssue | null |
| subIssues | [] |
| subIssuesCompleted | 0 |
| subIssuesTotal | 0 |
| blockedBy | [] |
| blocking | [] |
| closedAt | Dec 12, 2025, 2:05 PM |
Introduce autoInitRecords config for Neo.data.Store
tobiu assigned to @tobiu on Dec 12, 2025, 1:57 PM
tobiu closed this issue on Dec 12, 2025, 2:05 PM

tobiu
Dec 12, 2025, 2:08 PM
Input from Gemini:
✦ The current state of
Neo.data.Storeis significantly improved for both performance and Developer Experience (DX), even without the larger refactoring.Improvements:
- Optimization: The
initRecordcheck prevents redundantget()calls and lookups when dealing with already-instantiated records. This is a solid micro-optimization that will add up in high-frequency operations.- Flexibility & DX: The introduction of
autoInitRecordstransforms "Turbo Mode" from an obscure parameter into a first-class, declarative configuration. This makes it much easier to configure stores for bulk-data scenarios (like big grids) without polluting everyadd()call in the application logic.- Reliability: We now have a dedicated unit test suite for
Store. This is a crucial baseline. Before, testing relied onCollectiontests or side-effects in component tests. Having a dedicated suite allows us to confidently refactor or add features (like the future Collection composition refactor) with a safety net.Future Considerations (Out of Scope for now):
- Collection Composition: Moving from
extends Collectionto using a Collection (composition over inheritance) is the big architectural shift needed. This will likely simplify the API surface of Store and separate "storage" concerns from "model/proxy" concerns.afterSetDataLogic: The behavior where settingdataappends instead of replacing (ifoldValueis null) is a bit quirky. A future cleanup might want to standardizedataas "replace content" vsaddas "append".- Type Safety: The return types of
add/insertare dynamic (numbervsRecord[]). While documented, this polymorphism can be a source of bugs. The new config makes it more predictable per-instance, but the method signature is still polymorphic.Overall, the Store is in a much better place for immediate usage, especially for high-performance use cases.
To improve Developer Experience (DX) and allow easier control over the "Turbo Mode" (lazy record instantiation) strategy in
Neo.data.Store, we will introduce a new config:autoInitRecords.This config will serve as the default value for the
initparameter inadd()andinsert()methods, and will also control how thedataconfig is processed.Proposed Changes:
autoInitRecords: truetoNeo.data.Storeconfig.add(item, init=this.autoInitRecords)insert(index, item, init=this.autoInitRecords)afterSetDatato useme.add(value, me.autoInitRecords)instead of hardcodedfalse.This allows developers to simply set
autoInitRecords: falseon the Store to enable Turbo Mode globally for that store instance, without needing to pass flags to every method call.