LearnNewsExamplesServices
Frontmatter
id5164
titlemodel.Component: internalSetData() => add support for smart sub tree updates
stateClosed
labels
enhancement
assigneestobiu
createdAtDec 8, 2023, 2:24 PM
updatedAtDec 8, 2023, 2:27 PM
githubUrlhttps://github.com/neomjs/neo/issues/5164
authortobiu
commentsCount0
parentIssuenull
subIssues[]
subIssuesCompleted0
subIssuesTotal0
blockedBy[]
blocking[]
closedAtDec 8, 2023, 2:27 PM

model.Component: internalSetData() => add support for smart sub tree updates

Closed v8.1.0 enhancement
tobiu
tobiu commented on Dec 8, 2023, 2:24 PM

Inside Neo.examples.model.nestedData.MainContainer we have the following use case:

model: {
    data: {
        user: {
            details: {
                firstname: 'Nils',
                lastname : 'Dehl'
            }
        }
    }
}

So far, updating vm data props only worked with passing the path to a leaf:

updateButton2Text(value) {
    this.getModel().setData({
        'user.details.lastname': value
    });
}

It would improve the developer experience a lot, in case we can also pass objects:

updateButton2Text(value) {
    this.getModel().setData({
        'user.details': {
            lastname: value
        }
    });
}

In this case, we do want to update the lastname leaf, without deleting or changing firstname.

the new logic will enable us to do so and parse value based objects recursivly. if you pass nested objects which do not exist as data props yet, they will get added as new bindable data props:

updateButton2Text(value) {
    this.getModel().setData({
        'user.details': {
            foo: {
                bar: {
                    baz: 'hi deniz!'
                }
            }
        }
    });
}

however: this approach also means that existing objects will get modified. if you want to store an existing data record, it will get affected.

@ExtAnimal @deniztoprak @ThorstenRaab

tobiu added the enhancement label on Dec 8, 2023, 2:24 PM
tobiu assigned to @tobiu on Dec 8, 2023, 2:24 PM
tobiu referenced in commit 4935ae4 - "model.Component: internalSetData() => add support for smart sub tree updates #5164" on Dec 8, 2023, 2:27 PM
tobiu closed this issue on Dec 8, 2023, 2:27 PM