Skip to content

KBE3D / KBCore / Cesium / EventHelper

类: EventHelper

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.

示例

ts
const helper = new Cesium.EventHelper();

helper.add(someObject.event, listener1, this);
helper.add(otherObject.event, listener2, this);

// later...
helper.removeAll();

方法

add()

add(event: Event, listener: (...params: any[]) => any, scope?: any): RemoveCallback

Adds a listener to an event, and records the registration to be cleaned up later.

参数

event

Event

The event to attach to.

listener

(...params: any[]) => any

The function to be executed when the event is raised.

scope?

any

An optional object scope to serve as the <code>this</code> pointer in which the listener function will execute.

返回

RemoveCallback

A function that will remove this event listener when invoked.


removeAll()

removeAll(): void

Unregisters all previously added listeners.

返回

void

构造函数

构造函数

new EventHelper(): EventHelper

返回

EventHelper

KBE3D @3.0.0 Copyright © 2024-present KBE3D