JSFiddle - React, Tailwind, and code Playground
by neonms92
HTML
<div data-bind="text: theText">nope</div>
<div data-bind="text: theThing() === undefined ? '' : theThing().text">nope</div>
<div data-bind="text: log"></div>
JavaScript
function model() {
var self = this;
self.theText = ko.observable();
self.theThing = ko.observable();
self.log = ko.observable();
self.theText.subscribe(function() {
self.log(self.log() + " " + "Change");
});
self.theThing.subscribe(function() {
self.log(self.log() + " " + "Change");
});
}
var model = new model();
ko.applyBindings(model);
var b = 'Text B';
model.theText('Text A');
model.theText('Text B');
model.theText(b);
model.log(model.log() + "-");
var thing = { text: 'Text A' };
model.theThing({ text: 'Text A' });
model.theThing(thing);