Skip to content

Instantly share code, notes, and snippets.

@kwdowicz
Created April 5, 2018 15:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kwdowicz/74f37afa5c4f85ce7251268fd5530613 to your computer and use it in GitHub Desktop.
Save kwdowicz/74f37afa5c4f85ce7251268fd5530613 to your computer and use it in GitHub Desktop.
for(prop in this) {
// creating callbacks for each property
var _prop = prop + 'Callback';
this[_prop] = undefined;
// creating custom setters for each property
var _set = 'set' + prop;
this[_set] = new Function('value',`console.log('setting name: ' + value); if(value !== this.${prop}) { this.${prop} = value; this.${_set}(value); }`);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment