import EventListenerOptions from 'gs-events/src/EventListenerOptions.js'Constructor Summary
| Public Constructor | ||
| public |
constructor(scope: IEventDispatcher, once: Boolean, useCapture: Boolean, priority: Number) 创建一个侦听器选项对象。 |
since 1.0.0 |
Member Summary
| Public Members | ||
| public get |
指示侦听器是否在执行后,自动从派发器中移除。 |
since 1.0.0 |
| public get |
指示侦听器在派发事件时的优先级。 |
since 1.0.0 |
| public get |
获取侦听器的作用域对象。 |
since 1.0.0 |
| public get |
指示侦听器是否在捕获阶段处理事件。 |
since 1.0.0 |
Method Summary
| Public Methods | ||
| public |
initWithParams(options: Boolean | IEventListenerOptions): this 使用自定义的参数,初始化当前配置选项。 |
since 1.0.0 |
Public Constructors
public constructor(scope: IEventDispatcher, once: Boolean, useCapture: Boolean, priority: Number) since 1.0.0 source
创建一个侦听器选项对象。
Params:
| Name | Type | Attribute | Description |
| scope | IEventDispatcher |
|
指定侦听器的作用域对象。 |
| once | Boolean |
|
指示侦听器是否在执行后,自动从派发器中移除。 |
| useCapture | Boolean |
|
指示侦听器是否在捕获阶段处理事件。 |
| priority | Number |
|
指示侦听器在派发事件时的优先级(事件派发时会优先执行高优先级的侦听器)。 |
Public Members
Public Methods
public initWithParams(options: Boolean | IEventListenerOptions): this since 1.0.0 source
使用自定义的参数,初始化当前配置选项。
- 如果
options是一个Boolean类型的值,则将options视为 EventListenerOptions#useCapture。 - 如果
options是一个IEventListenerOptions类型的值,则拷贝options的值到当前配置选项中。
Params:
| Name | Type | Attribute | Description |
| options | Boolean | IEventListenerOptions |
|
指定侦听器的配置选项。 |
Return:
| this |
Example:
const dispatcher = new EventDispatcher();
const options = new EventListenerOptions();
options.initWithParams({ "once": true, "scope": this });
dispatcher.addEventListener("custom", ( evt ) => {
/// 该事件侦听器在执行后,会自动从 `dispatcher` 派发器中移除。
console.log("success");
}, options);
dispatcher.dispatchEvent(new Event("custom", false, false));
