Skip to content
目录

类EventDispatcher

事件调度器。

继承

方法

on

typescript
on(
    type: EventType | string,
    callback: (ev: EventArg) => void,
    once: boolean = false,
    data?: any
    ): string;

监听事件。

返回事件唯一编号,string 类型。

参数

事件类型。

回调函数。

  • onceboolean

是否只执行一次。默认值 false

  • dataany

自定义事件数据。默认值 undefined

once

typescript
once(
    type: EventType | string,
    callback: (ev: EventArg) => void,
    data?: any
    ): string;

监听事件仅一次。

返回事件唯一编号,string 类型。

参数

事件类型。

回调函数。

  • dataany

自定义事件数据。默认值 undefined

trigger

typescript
trigger(
    type: EventType | string,
    data?: any
    ): void;

触发指定类型的事件。

返回 void 类型。

参数

事件类型。

  • dataany

自定义事件数据。默认值 undefined

off

typescript
off(id: string): void;

移除指定编号的事件。

返回 void 类型。

参数

  • idstring

事件唯一编号。

offType

typescript
offType(type: EventType | string): void;

移除指定类型的事件。

返回 void 类型。

参数

事件类型。

offAll

typescript
offAll(): void;

移除所有事件。

返回 void 类型。

无参数。

pause

typescript
pause(...ids: string[]): void;

暂停事件响应。

返回 void 类型。

参数

  • ids...string[]

事件唯一编号列表。

resume

typescript
resume(...ids: string[]): void;

恢复事件响应。

返回 void 类型。

参数

  • ids...string[]

事件唯一编号列表。

技术支持:13352865103(柯工,微信同号);18688783852(柯工)