Home Reference Source
import IEventDispatcher from 'gs-events/src/IEventDispatcher.js'
public interface | since 1.0.0 | source

IEventDispatcher

Direct Implemented:

定义所有具备事件派发功能对象的接口。

Method Summary

Public Methods
public

注册一个事件侦听器。

since 1.0.0
public

派发一个事件对象到目标对象的事件流中。

since 1.0.0
public

检查是否注册了指定类型的事件侦听器。

since 1.0.0
public

移除一个事件侦听器。

since 1.0.0

Public Methods

public addEventListener(type: String | Symbol, handler: Function | IEventListener, options: Boolean | IEventListenerOptions) since 1.0.0 source

注册一个事件侦听器。

Params:

NameTypeAttributeDescription
type String | Symbol

注册的事件类型。

handler Function | IEventListener

指定事件处理函数或者是一个事件侦听器。

options Boolean | IEventListenerOptions
  • optional
  • default: false

指定侦听器配置选项。

public dispatchEvent(event: Event): Boolean since 1.0.0 source

派发一个事件对象到目标对象的事件流中。

Params:

NameTypeAttributeDescription
event Event

指定派发的事件对象。

Return:

Boolean

如果事件传递到了当前目标对象,并且没有被取消默认行为。则返回 true,否则返回 false

public hasEventListener(type: String | Symbol): Boolean since 1.0.0 source

检查是否注册了指定类型的事件侦听器。

Params:

NameTypeAttributeDescription
type String | Symbol

检查的事件类型。

Return:

Boolean

如果存在指定类型的侦听器则返回 true,否则返回 false

public removeEventListener(type: String | Symbol, handler: Function | IEventListener, useCapture: Boolean | IEventListenerOptions) since 1.0.0 source

移除一个事件侦听器。

Params:

NameTypeAttributeDescription
type String | Symbol

移除的事件类型。

handler Function | IEventListener

指定要移除的事件处理函数或者事件侦听器。

useCapture Boolean | IEventListenerOptions
  • optional
  • default: false

指定是移除捕获阶段(true)还是冒泡阶段(false)的事件侦听器。