JSFiddle - React, Tailwind, and code Playground

JavaScript

function myCallback(person, newName) {
    alert('Person ' + person.personName() + ' with age ' + person.personAge() + ' has a new name: ' + newName);
}

var Person = function() {
    var self = this;

    self.personName = ko.observable(null);
    self.personAge= ko.observable(null);

    self.personName.subscribe(function(newValue) {
        // "self" is a variable reference to the correct Person here
        // newValue is the new value for the observable
        // calling "myCallback" here allows you to pass those at your leisure
        myCallback(self, newValue);
    });
};


var john = new Person();
john.personName('john');
john.personAge(32);

john.personName('Johnnieboy');