JSFiddle - React, Tailwind, and code Playground
HTML
<script src="https://raw.github.com/melanke/Watch.JS/master/src/watch.js"></script>
JavaScript
//defining our object no matter which way we want
var ex1 = {
attr1: "initial value of attr1",
attr2: "initial value of attr2"
};
//defining a 'watcher' for an attribute
ex1.watch("attr1", function(prop, newvalue, oldvalue){
alert(prop+" - new: "+newvalue+", old: "+oldvalue);
});
//when changing the attribute its watcher will be invoked
ex1.attr1 = "other value";