EventHelper

external class EventHelper(source)

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.

const helper = new EventHelper();

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

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

See also

Constructors

Link copied to clipboard
constructor()

Functions

Link copied to clipboard
fun add(event: DefaultEvent, listener: () -> Unit, scope: Any? = definedExternally): RemoveCallback

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

Link copied to clipboard
fun removeAll()

Unregisters all previously added listeners.