Capture differential / delta payload in Knockout view model

56 views Asked by At

I am using a KO viewmodel which interfaces a REST end-point. The REST end-point serves me plain JSON data like:

var data = {
    "firstName": "John",
    "lastName": "Doe
};

Data is then transformed to a viewModel using ko.mapping as follows:

var viewModel = ko.mapping.fromJS(data);

On the view, it is possible only a part of the data will be modified, say firstName. In that case, I wish to construct a payload containing:

{
    "firstName": "Jane"
}

which I can then send to my server to perform an update only on those fields.

Is there any framework or utility (possibly in KO) which already does this?

0

There are 0 answers