LearnNewsExamplesServices
Frontmatter
id3196
titledata.RecordFactory: createRecord() => smarter matching to model instances
stateClosed
labels
bug
assigneestobiu
createdAtJun 25, 2022, 2:12 PM
updatedAtJun 25, 2022, 2:14 PM
githubUrlhttps://github.com/neomjs/neo/issues/3196
authortobiu
commentsCount0
parentIssuenull
subIssues[]
subIssuesCompleted0
subIssuesTotal0
blockedBy[]
blocking[]
closedAtJun 25, 2022, 2:14 PM

data.RecordFactory: createRecord() => smarter matching to model instances

Closed v8.1.0 bug
tobiu
tobiu commented on Jun 25, 2022, 2:12 PM

the current logic:

createRecord(model, config) {
    let recordClass = Neo.ns(this.recordNamespace + model.className);

    if (!recordClass) {
        recordClass = this.createRecordClass(model);
    }

    return new recordClass(config);
}

has a problem: each data.Store will create one instance of data.Model, which contains the storeId. In case multiple stores are using the same model class, the recordClass will just use the first created model instance. This can affect listeners, pointing to the wrong stores.

to solve this, we need to add the model.id into the record class namespace.

tobiu added the bug label on Jun 25, 2022, 2:12 PM
tobiu assigned to @tobiu on Jun 25, 2022, 2:12 PM
tobiu referenced in commit ca7581a - "data.RecordFactory: createRecord() => smarter matching to model instances #3196" on Jun 25, 2022, 2:13 PM
tobiu closed this issue on Jun 25, 2022, 2:14 PM