deferEvaluation

by uedatakuya

HTML

<input data-bind="value: x">+
<input data-bind="value: y">

JavaScript

var x = ko.observable(1);
var y = ko.observable(2);
ko.applyBindings({
    x: x,
    y: y,
    sum1: ko.computed({
        read: function () {
            console.log("read sum1");
            return x() + y();
        },
        deferEvaluation: true
    }),
    sum2: ko.computed({
        read: function () {
            console.log("read sum2");
            return x() + y();
        }
    })
});