@glowjs/core
Version:
GlowJS数字孪生引擎核心库。
68 lines (67 loc) • 1.79 kB
TypeScript
import { IDisposable } from '../base/IDisposable';
import { EventType } from './EventType';
import { EventArg } from './EventArg';
/**
* 事件调度器
*/
export declare class EventDispatcher implements IDisposable {
/**
* 事件字典
*/
private _eventMap;
/**
* 是否已经销毁
*/
_disposed: boolean;
/**
* 监听事件
* @param type 事件类型
* @param callback 回调函数
* @param once 是否只执行一次
* @param data 自定义事件数据
* @returns 事件唯一编号
*/
on(type: EventType | string, callback: (ev: EventArg) => void, once?: boolean, data?: any): string;
/**
* 监听事件仅一次
* @param type 事件类型
* @param callback 回调函数
* @param data 自定义事件数据
* @returns 事件唯一编号
*/
once(type: EventType | string, callback: (ev: EventArg) => void, data?: any): string;
/**
* 触发指定类型的事件
* @param type 事件类型
* @param data 自定义事件数据
*/
trigger(type: EventType | string, data?: any): void;
/**
* 移除指定编号的事件
* @param id 事件唯一编号
*/
off(id: string): void;
/**
* 移除指定类型的事件
* @param type 事件类型
*/
offType(type: EventType | string): void;
/**
* 移除所有事件
*/
offAll(): void;
/**
* 暂停事件响应
* @param ids 事件唯一编号列表
*/
pause(...ids: string[]): void;
/**
* 恢复事件响应
* @param ids 事件唯一编号列表
*/
resume(...ids: string[]): void;
/**
* 释放
*/
dispose(): void;
}