Created
January 22, 2016 04:19
-
-
Save stevemao/6f71429a08103c9bc7e0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
console = console || {}; // just in case | |
console.watch = function(oObj, sProp) { | |
sPrivateProp = "$_"+sProp+"_$"; // to minimize the name clash risk | |
oObj[sPrivateProp] = oObj[sProp]; | |
// overwrite with accessor | |
Object.defineProperty(oObj, sProp, { | |
get: function () { | |
return oObj[sPrivateProp]; | |
}, | |
set: function (value) { | |
//console.log("setting " + sProp + " to " + value); | |
debugger; // sets breakpoint | |
oObj[sPrivateProp] = value; | |
} | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment