mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
Fixed Issue #929.
This commit is contained in:
@@ -15,30 +15,29 @@ export class Observable implements definition.Observable {
|
||||
constructor(json?: any) {
|
||||
if (json) {
|
||||
this._map = new Map<string, Object>();
|
||||
|
||||
var definePropertyFunc = function definePropertyFunc(propertyName) {
|
||||
Object.defineProperty(Observable.prototype, propertyName, {
|
||||
get: function () {
|
||||
return this._map.get(propertyName);
|
||||
},
|
||||
set: function (value) {
|
||||
this._map.set(propertyName, value);
|
||||
this.notify(this._createPropertyChangeData(propertyName, value));
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
};
|
||||
|
||||
for (var prop in json) {
|
||||
if (json.hasOwnProperty(prop)) {
|
||||
definePropertyFunc(prop);
|
||||
this._defineNewProperty(prop);
|
||||
this.set(prop, json[prop]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private _defineNewProperty(propertyName: string): void {
|
||||
Object.defineProperty(this, propertyName, {
|
||||
get: function () {
|
||||
return this._map.get(propertyName);
|
||||
},
|
||||
set: function (value) {
|
||||
this._map.set(propertyName, value);
|
||||
this.notify(this._createPropertyChangeData(propertyName, value));
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
}
|
||||
|
||||
get typeName(): string {
|
||||
return types.getClass(this);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user