-
-
Save arv/b767ffb8161f1ad4051f 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
createPropertyAccessor: function(name, ignoreWrites) { | |
var proto = this.prototype; | |
var privateName = name + '_'; | |
var privateObservable = name + 'Observable_'; | |
Object.defineProperty(proto, name, { | |
get: function() { | |
var observable = this[privateObservable]; | |
if (observable) | |
observable.deliver(); | |
return this[privateName]; | |
}, | |
set: function(value) { | |
if (ignoreWrites) { | |
return; | |
} | |
var observable = this[privateObservable]; | |
if (observable) { | |
observable.setValue(value); | |
return; | |
} | |
var oldValue = this[privateName]; | |
this[privateName] = value; | |
this.emitPropertyChangeRecord(name, value, oldValue); | |
}, | |
configurable: true | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment