| 123456789101112131415161718192021222324252627282930313233343536373839 |
- export class SObjectObserver {
- /** 回调函数 */
- private readonly callback: Function;
- /** 信号接收者 */
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
- private readonly receiver: any = null;
- /**
- * 构造函数
- *
- * @param receiver 信号接收者
- * @param callback 回调函数
- */
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
- constructor(receiver: any, callback: Function) {
- this.receiver = receiver;
- this.callback = callback;
- } // Constructor
- /**
- * 发送通知
- *
- * @param args 参数
- */
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
- notify(...args: any): void {
- this.callback.call(this.receiver, ...args);
- } // Function notify()
- /**
- * 上信号接收者比较
- *
- * @param receiver 信号接收者
- */
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
- compar(receiver: any): boolean {
- return receiver == this.receiver;
- } // Function compar()
- } // Class EventObserver
|