LearnNewsExamplesServices
Frontmatter
id8078
titleEnhance Store DX: Add ''init'' parameter to add() and insert() for immediate record creation
stateClosed
labels
enhancementdeveloper-experienceai
assigneestobiu
createdAtDec 10, 2025, 11:59 AM
updatedAtDec 10, 2025, 12:07 PM
githubUrlhttps://github.com/neomjs/neo/issues/8078
authortobiu
commentsCount0
parentIssuenull
subIssues[]
subIssuesCompleted0
subIssuesTotal0
blockedBy[]
blocking[]
closedAtDec 10, 2025, 12:07 PM

Enhance Store DX: Add 'init' parameter to add() and insert() for immediate record creation

Closed v11.17.0 enhancementdeveloper-experienceai
tobiu
tobiu commented on Dec 10, 2025, 11:59 AM

Improve DX by allowing Neo.data.Store to return fully instantiated records directly from add() and insert().

Proposal: Overload add() and insert() in Neo.data.Store with an optional second parameter init=false.

  1. add(items, init=false)

    • If init is true, the method should return an Array of Record instances instead of the raw data objects.
    • It effectively combines add(items) + initRecord(item) for each added item.
  2. insert(index, items, init=false)

    • Similarly, allow insert to optionally initialize and return the created records.

Reasoning: Currently, lazy records requires a two-step process to get a usable Record instance:

store.add(data);
const record = store.get(id); // Required to get the Record

This change simplifies it to:

const [record] = store.add(data, true);

Architectural Note: This overloads the collection.Base signature. While slightly impure, the DX benefit for Store usage is significant.

tobiu added the enhancement label on Dec 10, 2025, 11:59 AM
tobiu added the developer-experience label on Dec 10, 2025, 11:59 AM
tobiu added the ai label on Dec 10, 2025, 11:59 AM
tobiu assigned to @tobiu on Dec 10, 2025, 12:00 PM
tobiu referenced in commit de32ae8 - "Enhance Store DX: Add 'init' parameter to add() and insert() for immediate record creation #8078" on Dec 10, 2025, 12:07 PM
tobiu closed this issue on Dec 10, 2025, 12:07 PM