ethers
Version:
A complete and compact Ethereum library, for dapps, wallets and any other tools.
42 lines • 1.13 kB
JavaScript
/**
* Events allow for applications to use the observer pattern, which
* allows subscribing and publishing events, outside the normal
* execution paths.
*
* @_section api/utils/events:Events [about-events]
*/
import { defineProperties } from "./properties.js";
/**
* When an [[EventEmitterable]] triggers a [[Listener]], the
* callback always ahas one additional argument passed, which is
* an **EventPayload**.
*/
export class EventPayload {
/**
* The event filter.
*/
filter;
/**
* The **EventEmitterable**.
*/
emitter;
/**
* Create a new **EventPayload** for %%emitter%% with
* the %%listener%% and for %%filter%%.
*/
constructor(emitter, listener, filter) {
this.
defineProperties(this, { emitter, filter });
}
/**
* Unregister the triggered listener for future events.
*/
async removeListener() {
if (this.
return;
}
await this.emitter.off(this.filter, this.
}
}
//# sourceMappingURL=events.js.map