LearnNewsExamplesServices
Frontmatter
id1813
titlemodel.Component: dynamically adding data props to a model that got defined without data
stateClosed
labels
enhancement
assigneestobiu
createdAtApr 19, 2021, 8:45 AM
updatedAtApr 19, 2021, 8:54 AM
githubUrlhttps://github.com/neomjs/neo/issues/1813
authortobiu
commentsCount1
parentIssuenull
subIssues[]
subIssuesCompleted0
subIssuesTotal0
blockedBy[]
blocking[]
closedAtApr 19, 2021, 8:54 AM

model.Component: dynamically adding data props to a model that got defined without data

Closed v8.1.0 enhancement
tobiu
tobiu commented on Apr 19, 2021, 8:45 AM

an edge case for sure.

we should use the constructor to assign an empty object to this.data.

E.g.:

    addDataProperty(key, value) {
        let me = this,
            data, scope;

        Neo.ns(key, true, me.data);

        data  = me.getDataScope(key);
        scope = data.scope;

        scope[data.key] = value;

        me.createDataProperties(me.data, 'data');
    }

The Neo.ns() call would not work in case data is undefined.

tobiu added the enhancement label on Apr 19, 2021, 8:45 AM
tobiu assigned to @tobiu on Apr 19, 2021, 8:45 AM
tobiu referenced in commit b1fcd52 - "model.Component: dynamically adding data props to a model that got defined without data #1813" on Apr 19, 2021, 8:45 AM
tobiu referenced in commit dfe3af2 - "#1813 getData() => removed the || {}, removed the ctor setter" on Apr 19, 2021, 8:53 AM
tobiu
tobiu Apr 19, 2021, 8:54 AM

never mind, we already have a beforeGetData() method in place. Adjusted getDataScope() to remove the default object.

tobiu closed this issue on Apr 19, 2021, 8:54 AM