JSFiddle - React, Tailwind, and code Playground
HTML
<script src="https://rawgithub.com/melanke/Watch.JS/master/src/watch.js"></script>
JavaScript
//defining our object no matter which way we want
var ex1 = {
attr1: "inicial value of attr1",
attr2: "initial value of attr2"
};
//defining a 'watcher' for an attribute
watch(ex1, "attr1", function(){
WatchJS.noMore = true; //prevent invoking watcher in this scope
ex1.attr2 = ex1.attr1 + " + 1";
});
//defining other 'watcher' for another attribute
watch(ex1, "attr2", function(){
alert("attr2 changes");
});
ex1.attr1 = "other value to 1"; //attr1 will be changed but will not invoke the attr2`s watcher