Fixed Issue #929.

This commit is contained in:
Rossen Hristov
2015-10-13 15:13:38 +03:00
parent e64fa80b56
commit d868642208
2 changed files with 58 additions and 18 deletions

View File

@@ -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);
}