JSFiddle - React, Tailwind, and code Playground
HTML
<div><input data-bind="value: a"/></div>
<div data-bind="text: f('simple')"></div>
<div data-bind="text: f('complex')"></div>
<div data-bind="text: c"></div>
JavaScript
function ViewModel() {
var $t = this;
this.a = ko.observable(5);
this.f = function(val) {
return $t.a() * (val === 'simple' ? 2: 10);
};
this.c = ko.computed(function() {
return $t.a() * 20;
});
};
ko.applyBindings(new ViewModel());