1

Since some time I research Object.observe function and wonder if it is possible to use it as 'a watcher' that help me to find function (with stack trace) that was the originator of the change. See code fragment below:

jQuery(function() {
    var struc = {
        a: 0
    };
    var spy = function (info) {
        console.log(info); // gives many details about what was changed, but not who made the change
        console.trace(); // it also doesn't give the information that 'callerFun' was originator of the change
    };
    var callerFun = function () {
        ++struc.a;
    };
    Object.observe(struc, spy);
    jQuery('body').bind('click', callerFun);
});

How can I get the information that callerFun changed the struc ?

0 Answers0