Skip to content

Commit d78503c

Browse files
committed
feat: 🎸 Added events: status, changed to the dealsRegistry
1 parent c51219b commit d78503c

File tree

1 file changed

+36
-5
lines changed

1 file changed

+36
-5
lines changed

‎src/client/dealsRegistry.ts

Lines changed: 36 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ export class DealsRegistry<
146146
.then(() => {
147147
this.checkInterval = setInterval(() => {
148148
this._checkDealsStates().catch(logger.error);
149-
}, 2000);
149+
}, 5000);
150150
})
151151
.catch(logger.error);
152152
}
@@ -360,7 +360,11 @@ export class DealsRegistry<
360360
txCallback,
361361
);
362362

363-
return await this._buildDealRecord(offer);
363+
const record = await this._buildDealRecord(offer);
364+
365+
this.dispatchEvent(new CustomEvent<void>('changed'));
366+
367+
return record;
364368
}
365369

366370
/**
@@ -436,7 +440,16 @@ export class DealsRegistry<
436440
txCallback,
437441
);
438442

439-
return await this._buildDealRecord(dealRecord.offer);
443+
const record = await this._buildDealRecord(dealRecord.offer);
444+
445+
this.dispatchEvent(
446+
new CustomEvent<DealRecord<CustomRequestQuery, CustomOfferOptions>>('status', {
447+
detail: record,
448+
}),
449+
);
450+
this.dispatchEvent(new CustomEvent<void>('changed'));
451+
452+
return record;
440453
}
441454

442455
/**
@@ -495,7 +508,16 @@ export class DealsRegistry<
495508
txCallback,
496509
);
497510

498-
return await this._buildDealRecord(dealRecord.offer);
511+
const record = await this._buildDealRecord(dealRecord.offer);
512+
513+
this.dispatchEvent(
514+
new CustomEvent<DealRecord<CustomRequestQuery, CustomOfferOptions>>('status', {
515+
detail: record,
516+
}),
517+
);
518+
this.dispatchEvent(new CustomEvent<void>('changed'));
519+
520+
return record;
499521
}
500522

501523
/**
@@ -547,6 +569,15 @@ export class DealsRegistry<
547569
txCallback,
548570
);
549571

550-
return await this._buildDealRecord(dealRecord.offer);
572+
const record = await this._buildDealRecord(dealRecord.offer);
573+
574+
this.dispatchEvent(
575+
new CustomEvent<DealRecord<CustomRequestQuery, CustomOfferOptions>>('status', {
576+
detail: record,
577+
}),
578+
);
579+
this.dispatchEvent(new CustomEvent<void>('changed'));
580+
581+
return record;
551582
}
552583
}

0 commit comments

Comments
 (0)