-
Notifications
You must be signed in to change notification settings - Fork 128
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement with Proxies #14
Comments
👍 |
Any help is appreciated! |
@paulirish Not sure it is possible in general case -- doesn't Proxy have to be a separate object? So it wouldn't help if you want to watch an object already referenced somewhere. |
@ashmind yeah true. the workflow is a little different. I suppose we could do something like Object.prototype.debug = function(){
var interceptor = {
set: function (receiver, property, value) {
console.trace(property, 'is changed to', value);
// debugger
receiver[property] = value;
}
};
return new Proxy(this, interceptor);
} which could enable creating the debuggable object at assignment: this.latLon = app.getLon().debug(); .... oh look at that, somebody already wrote this: check |
I suppose one benefit is that you can watch any properties, not just specified ones. |
ES6 Proxies could be used to pull off the same technique. It perhaps could have a few advantages over using getters.
They're now in most browsers:
The text was updated successfully, but these errors were encountered: