一个方便的对象,它简化了将事件侦听器附加到多个事件,然后立即删除所有这些侦听器的常见模式,例如在 destroy 方法中。 A convenience object that simplifies the common pattern of attaching event listeners to several events, then removing all those listeners at once later, for example, in a destroy method.
示例: Example:
const helper = new Cesium.EventHelper();
helper.add(someObject.event, listener1, this);
helper.add(otherObject.event, listener2, this);
// later...
helper.removeAll();
另见: See:
方法 Methods
add(event, listener, scope) → EventHelper.RemoveCallback
向事件添加侦听器,并记录注册以便稍后清理。 Adds a listener to an event, and records the registration to be cleaned up later.
| 名称 Name | 类型 Type | 说明 Description |
|---|---|---|
event |
Event | 要附加到的事件。 The event to attach to. |
listener |
function | 引发事件时要执行的函数。 The function to be executed when the event is raised. |
scope |
object |
可选 optional
一个可选的对象范围作为 An optional object scope to serve as the this
将在其中执行侦听器函数的指针。 pointer in which the listener function will execute. |
返回: Returns:
调用时将删除此事件侦听器的函数。 A function that will remove this event listener when invoked.
另见: See:
取消注册所有先前添加的侦听器。 Unregisters all previously added listeners.
另见: See:
类型定义 Type Definitions
删除侦听器的函数。 A function that removes a listener.
