UNPKG

@renproject/ren

Version:

Official Ren JavaScript SDK for bridging crypto assets cross-chain.

30 lines 1.2 kB
import { EventEmitter } from "events"; // The TransactionEmitter extends the built-in EventEmitter, adding the ability // to retrieve previous transactions that have been emitted. export class TransactionEmitter extends EventEmitter { constructor(getTransactions) { super(); this.addListener = (event, callback) => { // Emit previous deposit events. if (event === "transaction") { this.getTransactions().map(callback); } super.on(event, callback); return this; }; /** * `on` creates a new listener to `"transaction"` events, returning * [[GatewayTransaction]] instances. * * `on` extends `EventEmitter.on`, modifying it to immediately return all * previous `"transaction"` events, in addition to new events, when a new * listener is created. * * @category Main */ this.on = (event, callback) => this.addListener(event, callback); this.once = (event, callback) => super.once(event, callback); this.getTransactions = getTransactions; } } //# sourceMappingURL=transactionEmitter.js.map