| 123456789101112131415161718192021 |
- /**
- * 数据对象
- * 通过DataSystem.createData来实例化对象,否则将无法使用DataSystem.watch
- */
- export class Data {
- onPropertyChange: (key: PropertyKey, value: any) => void;
- thisObject: any;
- public constructor(onPropertyChange: (key: PropertyKey, value: any) => void, thisObject: any) {
- this.onPropertyChange = onPropertyChange;
- this.thisObject = thisObject;
- var p = new Proxy(this, { set: this.setProperty.bind(this), deleteProperty: this.deleteProperty.bind(this) });
- return p;
- }
- protected setProperty<T>(target: T, p: PropertyKey, value: any, receiver: any): boolean {
- this.onPropertyChange.call(this.thisObject, this, p, value);
- return true;
- }
- private deleteProperty<T>(target: T, p: PropertyKey): boolean {
- return true;
- }
- }
|