JSFiddle - React, Tailwind, and code Playground
by EstSiim
HTML
<p>Age:
<input data-bind="value:age" />
</p>
<p>Age has been changed: <span data-bind="text:ageChangeCount"></span> times</p>
JavaScript
function viewModel() {
var self = this;
self.age = ko.observable(10).extend({
notify: 'always'
}),
self.ageChangeCount = ko.observable(0),
self.age.subscribe(function (val) {
console.log('Someone has changed age');
self.ageChangeCount(self.ageChangeCount() + 1);
});
};
ko.applyBindings(new viewModel());