JSFiddle - React, Tailwind, and code Playground
HTML
<p>I want this to update to 35 then 45 <input data-bind='value: comp1' /></p>
<p>I want this to update to 22 then 45 <input data-bind='value: comp2' /></p>
JavaScript
var ViewModel = function() {
var self = this;
self.obs1 = ko.observable(10);
self.obs2 = ko.observable(2);
//I want this computed to behave normally
self.comp1 = ko.computed(function() {
return self.obs1() + self.obs2();
}, this);
//Possible solution?
self.obs2DelayComp = ko.computed(function() {
return self.obs2();
}).extend({ rateLimit: 3001 });
//I want this computed to trigger on obs1 update but ignore updates to obs2
self.comp2 = ko.computed(function() {
return self.obs1() + self.obs2DelayComp();
}, this);
setTimeout(function() {
self.obs1(20);
self.obs2(15);
}, 1000);
setTimeout(function() {
self.obs1(30);
}, 3000);
};
ko.applyBindings(new ViewModel());