ethers.js/lib.commonjs/utils/events.js

44 lines
1.1 KiB
JavaScript
Raw Permalink Normal View History

2022-09-05 16:57:11 -04:00
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.EventPayload = void 0;
2022-11-30 15:44:23 -05:00
/**
* Explain events...
*
2022-12-02 21:27:06 -05:00
* @_section api/utils/events:Events [about-events]
2022-11-30 15:44:23 -05:00
*/
2022-09-05 16:57:11 -04:00
const properties_js_1 = require("./properties.js");
2023-01-28 01:53:29 -05:00
/**
* When an [[EventEmitterable]] triggers a [[Listener]], the
* callback always ahas one additional argument passed, which is
* an **EventPayload**.
*/
2022-09-05 16:57:11 -04:00
class EventPayload {
2023-01-28 01:53:29 -05:00
/**
* The event filter.
*/
2022-09-05 16:57:11 -04:00
filter;
2023-01-28 01:53:29 -05:00
/**
* The **EventEmitterable**.
*/
2022-09-05 16:57:11 -04:00
emitter;
#listener;
2023-01-28 01:53:29 -05:00
/**
* Create a new **EventPayload** for %%emitter%% with
* the %%listener%% and for %%filter%%.
*/
2022-09-05 16:57:11 -04:00
constructor(emitter, listener, filter) {
this.#listener = listener;
(0, properties_js_1.defineProperties)(this, { emitter, filter });
}
2023-01-28 01:53:29 -05:00
/**
* Unregister the triggered listener for future events.
*/
2022-09-05 16:57:11 -04:00
async removeListener() {
if (this.#listener == null) {
return;
}
await this.emitter.off(this.filter, this.#listener);
}
}
exports.EventPayload = EventPayload;
//# sourceMappingURL=events.js.map