Files
kunpolibrary/src/data/DataBase.ts

45 lines
1.0 KiB
TypeScript
Raw Normal View History

import { BindManager } from './BindManager';
import { ProxyObject } from './ProxyHandler';
import { BindInfo } from './types';
/**
*
* Proxy 访
*/
export class DataBase {
/** 响应式对象唯一标识 */
private __data_id__: string;
/** 绑定器集合 */
private __watchers__: Set<BindInfo>;
/** 是否已销毁 */
private __destroyed__: boolean = false;
constructor() {
// 返回包装后的对象,自动使用 constructor.name
return ProxyObject(this);
}
/**
*
*/
public destroy(): void {
this.__destroyed__ = true;
this.__watchers__.clear();
BindManager.cleanup(this);
}
/**
* ID
*/
public getDataId(): string {
return this.__data_id__;
}
/**
*
*/
public isDestroyed(): boolean {
return this.__destroyed__;
}
}